Skip to content

Commit

Permalink
feat(chat): Removing dynamic scoping from chat section
Browse files Browse the repository at this point in the history
Closes #4244
  • Loading branch information
alexandraB99 committed Jul 12, 2022
1 parent 5bbc800 commit eec1390
Show file tree
Hide file tree
Showing 23 changed files with 219 additions and 111 deletions.
23 changes: 16 additions & 7 deletions ui/app/AppLayouts/Chat/ChatLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ StackLayout {
}

property alias chatView: chatView
signal importCommunityClicked()
signal createCommunityClicked()

clip: true

Expand All @@ -40,6 +42,13 @@ StackLayout {

onCommunityInfoButtonClicked: root.currentIndex = 1
onCommunityManageButtonClicked: root.currentIndex = 1

onImportCommunityClicked: {
root.importCommunityClicked();
}
onCreateCommunityClicked: {
root.createCommunityClicked();
}
}

Loader {
Expand All @@ -53,14 +62,14 @@ StackLayout {
community: root.rootStore.mainModuleInst ? root.rootStore.mainModuleInst.activeSection
|| {} : {}

onBackToCommunityClicked: root.currentIndex = 0
onBackToCommunityClicked: root.currentIndex = 0

// TODO: remove me when migration to new settings is done
onOpenLegacyPopupClicked: Global.openPopup(communityProfilePopup, {
"store": root.rootStore,
"community": community,
"communitySectionModule": chatCommunitySectionModule
})
// TODO: remove me when migration to new settings is done
onOpenLegacyPopupClicked: Global.openPopup(Global.communityProfilePopup, {
"store": root.rootStore,
"community": community,
"communitySectionModule": chatCommunitySectionModule
})
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ import StatusQ.Core.Utils 0.1 as StatusQUtils
Item {
id: replyComponent

property int repliedMessageId: wrapper.repliedMessageId
property string repliedMessageContent: wrapper.repliedMessageContent

onRepliedMessageIdChanged: {
wrapper.visible = (repliedMessageId.length > 0)
}
property string repliedMessageContent

SVGImage {
id: replyIcon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ Item {
width: parent.width
height: 64

property bool hasMentions: false
property bool hasReplies: false
property bool hideReadNotifications: false
property bool allBtnHighlighted: false
property bool repliesBtnHighlighted: false
property bool mentionsBtnHighlighted: false
property alias repliesBtnEnabled: repliesbtn.enabled
property alias mentionsBtnEnabled: mentionsBtn.enabled
property alias errorText: errorText.text
signal allBtnClicked()
signal repliesBtnClicked()
signal mentionsBtnClicked()
signal preferencesClicked()
signal markAllReadClicked()
signal hideReadNotificationsTriggered()

Row {
id: filterButtons
Expand Down
5 changes: 3 additions & 2 deletions ui/app/AppLayouts/Chat/panels/ActivityChannelBadgePanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Rectangle {
property string communityName: ""
property string communityColor: ""
property string communityThumbnailImage: ""
property string repliedMessageId: ""
property int repliedMessageId
property string repliedMessageContent: ""
property int notificationType
property string profileImage: ""
Expand All @@ -36,6 +36,8 @@ Rectangle {
border.color: Style.current.borderSecondary
border.width: 1
radius: 11
visible: (repliedMessageId > -1)


Loader {
active: true
Expand All @@ -56,7 +58,6 @@ Rectangle {
ActivityCenter.ReplyComponent {
width: childrenRect.width
height: parent.height
repliedMessageId: wrapper.repliedMessageId
repliedMessageContent: wrapper.repliedMessageContent
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import utils 1.0

Rectangle {
id: root

property string communityId
signal addMembersClicked()
signal addCategoriesClicked()

height: childrenRect.height + Style.current.padding
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
Expand All @@ -22,8 +27,6 @@ Rectangle {
border.color: Style.current.border
radius: 16
color: Style.current.transparent
property string communityId


Rectangle {
width: 66
Expand Down Expand Up @@ -86,7 +89,9 @@ Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: descriptionText.bottom
anchors.topMargin: Style.current.padding
onClicked: Global.openPopup(createChannelPopup)
onClicked: {
root.addMembersClicked();
}
}

StatusFlatButton {
Expand All @@ -95,6 +100,8 @@ Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: addMembersBtn.bottom

onClicked: Global.openPopup(createCategoryPopup)
onClicked: {
root.addCategoriesClicked();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: manageBtn.top
anchors.bottomMargin: Style.current.halfPadding
onClicked: Global.openPopup(inviteFriendsToCommunityPopup, {
onClicked: Global.openPopup(Global.inviteFriendsToCommunityPopup, {
community: root.activeCommunity,
hasAddedContacts: root.hasAddedContacts,
communitySectionModule: root.communitySectionModule
Expand Down
14 changes: 10 additions & 4 deletions ui/app/AppLayouts/Chat/popups/ActivityCenterPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ Popup {

ActivityCenterPopupTopBarPanel {
id: activityCenterTopBar
repliesBtnEnabled: hasReplies
mentionsBtnEnabled: hasMentions
hasReplies: activityCenter.hasReplies
hasMentions: activityCenter.hasMentions
hideReadNotifications: activityCenter.hideReadNotifications
allBtnHighlighted: activityCenter.currentFilter === ActivityCenterPopup.Filter.All
mentionsBtnHighlighted: activityCenter.currentFilter === ActivityCenterPopup.Filter.Mentions
repliesBtnHighlighted: activityCenter.currentFilter === ActivityCenterPopup.Filter.Replies
Expand Down Expand Up @@ -211,14 +212,17 @@ Popup {
ActivityCenterMessageComponentView {
id: activityCenterMessageView
store: activityCenter.store
acCurrentFilter: activityCenter.currentFilter
chatSectionModule: activityCenter.chatSectionModule
messageContextMenu: activityCenter.messageContextMenu

hideReadNotifications: activityCenter.hideReadNotifications
Connections {
target: activityCenter
onOpened: activityCenterMessageView.reevaluateItemBadge()
}

onActivityCenterClose: {
activityCenter.close();
}
Component.onCompleted: {
activityCenterMessageView.reevaluateItemBadge()
}
Expand All @@ -230,6 +234,8 @@ Popup {

ActivityCenterGroupRequest {
store: activityCenter.store
hideReadNotifications: activityCenter.hideReadNotifications
acCurrentFilterAll: activityCenter.currentFilter === ActivityCenter.Filter.All
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions ui/app/AppLayouts/Chat/popups/GroupInfoPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ StatusModal {
property int channelType: GroupInfoPopup.ChannelType.ActiveChannel
property var chatDetails
property bool isAdmin: popup.chatSectionModule.activeItem.amIChatAdmin
property Component pinnedMessagesPopupComponent

property var chatContentModule

Expand Down Expand Up @@ -176,7 +175,7 @@ StatusModal {
popup.store.messageStore.messageModule = popup.chatContentModule.messagesModule
popup.store.messageStore.chatSectionModule = popup.chatSectionModule

Global.openPopup(pinnedMessagesPopupComponent, {
Global.openPopup(Global.pinnedMessagesPopup, {
store: popup.store,
messageStore: popup.store.messageStore,
pinnedMessagesModel: popup.chatContentModule.pinnedMessagesModel,
Expand Down
11 changes: 8 additions & 3 deletions ui/app/AppLayouts/Chat/popups/community/CommunitiesPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ StatusModal {
property var communitiesList
signal setActiveCommunity(string id)
signal setObservedCommunity(string id)
signal openCommunityDetail()
signal importCommunityClicked()
signal createCommunityClicked()

onOpened: {
contentItem.searchBox.input.text = "";
Expand All @@ -39,7 +42,9 @@ StatusModal {
StatusMenuItem {
icon.name: "download"
text: qsTr("Access existing community")
onTriggered: Global.openPopup(importCommunitiesPopupComponent)
onTriggered: {
popup.importCommunityClicked();
}
}
}
}
Expand Down Expand Up @@ -131,7 +136,7 @@ StatusModal {
popup.setActiveCommunity(model.id);
} else {
popup.setObservedCommunity(model.id);
Global.openPopup(communityDetailPopup)
popup.openCommunityDetail();
}
popup.close()
}
Expand All @@ -145,7 +150,7 @@ StatusModal {
StatusButton {
text: qsTr("Create a community")
onClicked: {
Global.openPopup(createCommunitiesPopupComponent)
popup.createCommunityClicked();
popup.close()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ StatusModal {
icon.width: 20
rotation: 180
onClicked: {
Global.openPopup(communitiesPopupComponent)
root.close()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ StatusModal {
anchors.horizontalCenter: parent.horizontalCenter
property var contactDetails: Utils.getContactDetailsAsJson(model.pubKey)

property string displayName: contactDetails.displayName || root.store.generateAlias(model.pubKey)

property string displayName: contactDetails.displayName || popup.store.generateAlias(model.pubKey)
image.source: contactDetails.thumbnailImage

title: displayName

components: [
Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Chat/stores/RootStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ QtObject {
property string createChatStickerHashId: ""
property string createChatStickerPackId: ""

property var groupInfoPopupComponent
property var membershipRequestPopup
property var contactsModel: root.contactsStore.myContactsModel

// Important:
Expand Down
4 changes: 3 additions & 1 deletion ui/app/AppLayouts/Chat/views/ActivityCenterGroupRequest.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Item {
property var store
property int previousNotificationIndex
property string previousNotificationTimestamp
property bool hideReadNotifications: false
property bool acCurrentFilterAll: false

DateGroup {
id: dateGroupLbl
Expand All @@ -40,7 +42,7 @@ Item {
return false
}

return activityCenter.currentFilter === ActivityCenter.Filter.All
return acCurrentFilterAll;
}
width: parent.width
height: visible ? 60 : 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,25 @@ Item {
if (hideReadNotifications && model.read) {
return false
}
return activityCenter.currentFilter === ActivityCenterPopup.Filter.All ||
(model.notificationType === Constants.activityCenterNotificationTypeMention && activityCenter.currentFilter === ActivityCenterPopup.Filter.Mentions) ||
(model.notificationType === Constants.activityCenterNotificationTypeOneToOne && activityCenter.currentFilter === ActivityCenterPopup.Filter.ContactRequests) ||
(model.notificationType === Constants.activityCenterNotificationTypeReply && activityCenter.currentFilter === ActivityCenterPopup.Filter.Replies)
return acCurrentFilter === ActivityCenterPopup.Filter.All ||
(model.notificationType === Constants.activityCenterNotificationTypeMention && acCurrentFilter === ActivityCenterPopup.Filter.Mentions) ||
(model.notificationType === Constants.activityCenterNotificationTypeOneToOne && acCurrentFilter === ActivityCenterPopup.Filter.ContactRequests) ||
(model.notificationType === Constants.activityCenterNotificationTypeReply && acCurrentFilter === ActivityCenterPopup.Filter.Replies)
}

property var store
property int acCurrentFilter
property var chatSectionModule
property int previousNotificationIndex
property bool hideReadNotifications
property string previousNotificationTimestamp
// Not Refactored Yet
property int communityIndex: -1 //root.store.chatsModelInst.communities.joinedCommunities.getCommunityIndex(model.message.communityId)
property var messageContextMenu
function openProfile() {
Global.openProfilePopup(model.author)
}
signal activityCenterClose()

function reevaluateItemBadge() {
let details = root.store.getBadgeDetails(model.sectionId, model.chatId)
Expand Down Expand Up @@ -145,7 +148,7 @@ Item {
return Global.openProfilePopup(model.message.senderId);
}

activityCenter.close()
activityCenterClose()
root.store.activityCenterModuleInst.switchTo(model.sectionId, model.chatId, model.id)
}
prevMessageIndex: root.previousNotificationIndex
Expand Down Expand Up @@ -191,11 +194,11 @@ Item {

onCommunityNameClicked: {
root.store.activityCenterModuleInst.switchTo(model.sectionId, "", "")
activityCenter.close()
activityCenterClose();
}
onChannelNameClicked: {
root.store.activityCenterModuleInst.switchTo(model.sectionId, model.chatId, "")
activityCenter.close()
activityCenterClose();
}
}
}
Expand Down
Loading

0 comments on commit eec1390

Please sign in to comment.