From fbc10e76655dbc2f551cfaa022a09da7e0cc93d3 Mon Sep 17 00:00:00 2001 From: Boris Melnik Date: Tue, 26 Jul 2022 17:23:45 +0300 Subject: [PATCH] fix(CreateChatView): Move `ActivityCenterPopup` to appmain Closes: #6345 --- .../Chat/popups/ActivityCenterPopup.qml | 70 ++++++++++--------- ui/app/AppLayouts/Chat/popups/qmldir | 1 + ui/app/AppLayouts/Chat/stores/RootStore.qml | 1 + .../AppLayouts/Chat/views/ChatColumnView.qml | 33 +++------ ui/app/AppLayouts/Chat/views/ChatView.qml | 1 - .../AppLayouts/Chat/views/CreateChatView.qml | 5 +- ui/app/mainui/AppMain.qml | 21 +++++- ui/imports/utils/Global.qml | 7 ++ 8 files changed, 77 insertions(+), 62 deletions(-) diff --git a/ui/app/AppLayouts/Chat/popups/ActivityCenterPopup.qml b/ui/app/AppLayouts/Chat/popups/ActivityCenterPopup.qml index 9559124772..e07326e357 100644 --- a/ui/app/AppLayouts/Chat/popups/ActivityCenterPopup.qml +++ b/ui/app/AppLayouts/Chat/popups/ActivityCenterPopup.qml @@ -8,12 +8,16 @@ import StatusQ.Controls 0.1 import shared 1.0 import shared.popups 1.0 +import shared.views.chat 1.0 + import utils 1.0 import "../views" import "../panels" Popup { + id: root + enum Filter { All, Mentions, @@ -28,11 +32,13 @@ Popup { property bool hideReadNotifications: false property var store property var chatSectionModule - property var messageContextMenu + property var messageContextMenu: MessageContextMenuView { + store: root.store + reactionModel: root.store.emojiReactionsModel + } - readonly property int unreadNotificationsCount : activityCenter.store.activityCenterList.unreadCount + readonly property int unreadNotificationsCount : root.store.activityCenterList.unreadCount - id: activityCenter modal: false closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside @@ -55,7 +61,7 @@ Popup { color: Style.current.dropShadow } } - x: Global.applicationWindow.width - activityCenter.width - Style.current.halfPadding + x: Global.applicationWindow.width - root.width - Style.current.halfPadding onOpened: { Global.popupOpened = true } @@ -66,27 +72,27 @@ Popup { ActivityCenterPopupTopBarPanel { id: activityCenterTopBar - 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 + hasReplies: root.hasReplies + hasMentions: root.hasMentions + hideReadNotifications: root.hideReadNotifications + allBtnHighlighted: root.currentFilter === ActivityCenterPopup.Filter.All + mentionsBtnHighlighted: root.currentFilter === ActivityCenterPopup.Filter.Mentions + repliesBtnHighlighted: root.currentFilter === ActivityCenterPopup.Filter.Replies onAllBtnClicked: { - activityCenter.currentFilter = ActivityCenterPopup.Filter.All; + root.currentFilter = ActivityCenterPopup.Filter.All; } onRepliesBtnClicked: { - activityCenter.currentFilter = ActivityCenterPopup.Filter.Replies; + root.currentFilter = ActivityCenterPopup.Filter.Replies; } onMentionsBtnClicked: { - activityCenter.currentFilter = ActivityCenterPopup.Filter.Mentions; + root.currentFilter = ActivityCenterPopup.Filter.Mentions; } onPreferencesClicked: { - activityCenter.close() + root.close() Global.changeAppSectionBySectionType(Constants.appSection.profile, Constants.settingsSubsection.notifications); } onMarkAllReadClicked: { - errorText = activityCenter.store.activityCenterModuleInst.markAllActivityCenterNotificationsRead() + errorText = root.store.activityCenterModuleInst.markAllActivityCenterNotificationsRead() } } @@ -108,11 +114,11 @@ Popup { // TODO remove this once it is handled by the activity center // Repeater { // id: contactList -// model: activityCenter.store.contactRequests +// model: root.store.contactRequests // delegate: ContactRequest { // visible: !hideReadNotifications && -// (activityCenter.currentFilter === ActivityCenter.Filter.All || activityCenter.currentFilter === ActivityCenter.Filter.ContactRequests) +// (root.currentFilter === ActivityCenter.Filter.All || root.currentFilter === ActivityCenter.Filter.ContactRequests) // name: Utils.removeStatusEns(model.name) // address: model.address // localNickname: model.localNickname @@ -142,7 +148,7 @@ Popup { function(left, right) { return left.timestamp > right.timestamp } ] - model: activityCenter.store.activityCenterList + model: root.store.activityCenterList delegate: Item { id: notificationDelegate @@ -180,9 +186,9 @@ Popup { } return -1; } - property string previousNotificationTimestamp: notificationDelegate.idx === 0 ? "" : activityCenter.store.activityCenterList.getNotificationData(previousNotificationIndex, "timestamp") + property string previousNotificationTimestamp: notificationDelegate.idx === 0 ? "" : root.store.activityCenterList.getNotificationData(previousNotificationIndex, "timestamp") onPreviousNotificationTimestampChanged: { - activityCenter.store.messageStore.prevMsgTimestamp = previousNotificationTimestamp; + root.store.messageStore.prevMsgTimestamp = previousNotificationTimestamp; } id: notifLoader @@ -212,17 +218,17 @@ Popup { ActivityCenterMessageComponentView { id: activityCenterMessageView - store: activityCenter.store - acCurrentFilter: activityCenter.currentFilter - chatSectionModule: activityCenter.chatSectionModule - messageContextMenu: activityCenter.messageContextMenu - hideReadNotifications: activityCenter.hideReadNotifications + store: root.store + acCurrentFilter: root.currentFilter + chatSectionModule: root.chatSectionModule + messageContextMenu: root.messageContextMenu + hideReadNotifications: root.hideReadNotifications Connections { - target: activityCenter + target: root onOpened: activityCenterMessageView.reevaluateItemBadge() } onActivityCenterClose: { - activityCenter.close(); + root.close(); } Component.onCompleted: { activityCenterMessageView.reevaluateItemBadge() @@ -234,16 +240,16 @@ Popup { id: groupRequestNotificationComponent ActivityCenterGroupRequest { - store: activityCenter.store - hideReadNotifications: activityCenter.hideReadNotifications - acCurrentFilterAll: activityCenter.currentFilter === ActivityCenter.Filter.All + store: root.store + hideReadNotifications: root.hideReadNotifications + acCurrentFilterAll: root.currentFilter === ActivityCenter.Filter.All } } } } Item { - visible: activityCenter.store.activityCenterModuleInst.hasMoreToShow + visible: root.store.activityCenterModuleInst.hasMoreToShow width: parent.width height: visible ? showMoreBtn.height + showMoreBtn.anchors.topMargin : 0 StatusButton { @@ -252,7 +258,7 @@ Popup { anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top anchors.topMargin: Style.current.smallPadding - onClicked: activityCenter.store.activityCenterModuleInst.loadMoreNotifications() + onClicked: root.store.activityCenterModuleInst.loadMoreNotifications() } } } diff --git a/ui/app/AppLayouts/Chat/popups/qmldir b/ui/app/AppLayouts/Chat/popups/qmldir index 8aeceb4612..bc5e8a7a47 100644 --- a/ui/app/AppLayouts/Chat/popups/qmldir +++ b/ui/app/AppLayouts/Chat/popups/qmldir @@ -2,3 +2,4 @@ PinnedMessagesPopup 1.0 PinnedMessagesPopup.qml ChooseBrowserPopup 1.0 ChooseBrowserPopup.qml InviteFriendsToCommunityPopup 1.0 community/InviteFriendsToCommunityPopup.qml CommunityProfilePopup 1.0 community/CommunityProfilePopup.qml +ActivityCenterPopup 1.0 ActivityCenterPopup.qml diff --git a/ui/app/AppLayouts/Chat/stores/RootStore.qml b/ui/app/AppLayouts/Chat/stores/RootStore.qml index a27347ad66..17d03fe760 100644 --- a/ui/app/AppLayouts/Chat/stores/RootStore.qml +++ b/ui/app/AppLayouts/Chat/stores/RootStore.qml @@ -122,6 +122,7 @@ QtObject { property var mainModuleInst: mainModule property var activityCenterModuleInst: activityCenterModule property var activityCenterList: activityCenterModuleInst.model + property int unreadNotificationsCount: activityCenterList.unreadCount property var communitiesModuleInst: communitiesModule property var communitiesList: communitiesModuleInst.model diff --git a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml index 0e46f1de9d..a1c2c78f39 100644 --- a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml @@ -58,8 +58,6 @@ Item { property bool contactRequestReceived: root.contactDetails.requestReceived property Component pinnedMessagesListPopupComponent - property alias activityCenter: activityCenter - signal openAppSearch() signal openStickerPackPopup(string stickerPackId) @@ -155,12 +153,6 @@ Item { } } - MessageContextMenuView { - id: contextmenu - store: root.rootStore - reactionModel: root.rootStore.emojiReactionsModel - } - EmptyChatPanel { anchors.fill: parent visible: root.activeChatId === "" || root.chatsCount == 0 @@ -233,14 +225,14 @@ Item { stickersLoaded: root.stickersLoaded isBlocked: model.blocked isActiveChannel: categoryChatLoader.isActiveChannel - activityCenterVisible: activityCenter.visible - activityCenterNotificationsCount: activityCenter.unreadNotificationsCount + activityCenterVisible: Global.activityCenterPopupOpened + activityCenterNotificationsCount: root.rootStore.unreadNotificationsCount pinnedMessagesPopupComponent: root.pinnedMessagesListPopupComponent onOpenStickerPackPopup: { root.openStickerPackPopup(stickerPackId) } onNotificationButtonClicked: { - activityCenter.open(); + Global.openActivityCenterPopup() } onOpenAppSearch: { root.openAppSearch(); @@ -264,13 +256,13 @@ Item { width: parent.width height: isActiveChannel ? parent.height : 0 Connections { - id: loaderConnections + id: defaultLoaderConnections target: chatLoader // First time this channel turns active, activate the Loader onIsActiveChannelChanged: { if (chatLoader.isActiveChannel) { chatLoader.active = true - loaderConnections.enabled = false + defaultLoaderConnections.enabled = false } } } @@ -290,14 +282,14 @@ Item { stickersLoaded: root.stickersLoaded isBlocked: model.blocked isActiveChannel: chatLoader.isActiveChannel - activityCenterVisible: activityCenter.visible - activityCenterNotificationsCount: activityCenter.unreadNotificationsCount + activityCenterVisible: Global.activityCenterPopupOpened + activityCenterNotificationsCount: root.rootStore.unreadNotificationsCount pinnedMessagesPopupComponent: root.pinnedMessagesListPopupComponent onOpenStickerPackPopup: { root.openStickerPackPopup(stickerPackId) } onNotificationButtonClicked: { - activityCenter.open(); + Global.openActivityCenterPopup() } onOpenAppSearch: { root.openAppSearch(); @@ -414,15 +406,6 @@ Item { } } - ActivityCenterPopup { - id: activityCenter - height: root.height - 56 * 2 // TODO get screen size // Taken from old code top bar height was fixed there to 56 - y: 56 - store: root.rootStore - chatSectionModule: root.parentModule - messageContextMenu: contextmenu - } - // Not Refactored Yet // Connections { // target: root.rootStore.chatsModelInst.stickers diff --git a/ui/app/AppLayouts/Chat/views/ChatView.qml b/ui/app/AppLayouts/Chat/views/ChatView.qml index 6e78f8ef02..11264be72d 100644 --- a/ui/app/AppLayouts/Chat/views/ChatView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatView.qml @@ -25,7 +25,6 @@ StatusAppThreePanelLayout { property var contactsStore property bool hasAddedContacts: root.contactsStore.myContactsModel.count > 0 - property alias activityCenter: chatColumn.activityCenter property RootStore rootStore diff --git a/ui/app/AppLayouts/Chat/views/CreateChatView.qml b/ui/app/AppLayouts/Chat/views/CreateChatView.qml index ed1654f1de..de51ab381e 100644 --- a/ui/app/AppLayouts/Chat/views/CreateChatView.qml +++ b/ui/app/AppLayouts/Chat/views/CreateChatView.qml @@ -18,7 +18,6 @@ Page { property ListModel contactsModel: ListModel { } property var rootStore - property var activityCenter: null property var emojiPopup: null Keys.onEscapePressed: Global.closeCreateChatView() @@ -135,8 +134,8 @@ Page { width: parent.width height: parent.height tooltip.offset: width/2 - unreadNotificationsCount: activityCenter.unreadNotificationsCount - onClicked: activityCenter.open() + unreadNotificationsCount: root.rootStore.unreadNotificationsCount + onClicked: Global.openActivityCenterPopup() } } } diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index 85386d3b01..0b88b12c31 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -89,6 +89,12 @@ Item { popup.openPopup(publicKey, state); Global.profilePopupOpened = true; } + + onOpenActivityCenterPopupRequested: { + Global.openPopup(activityCenterPopupComponent) + Global.activityCenterPopupOpened = true + } + onOpenChangeProfilePicPopup: { var popup = changeProfilePicComponent.createObject(appMain); popup.chooseImageToCrop(); @@ -651,7 +657,6 @@ Item { property bool opened: false rootStore: chatLayoutContainer.rootStore - activityCenter: chatLayoutContainer.chatView.activityCenter emojiPopup: statusEmojiPopup anchors.top: parent.top anchors.topMargin: 8 @@ -762,6 +767,20 @@ Item { } } + Component { + id: activityCenterPopupComponent + ActivityCenterPopup { + id: activityCenter + height: appView.height - 56 * 2 // TODO get screen size // Taken from old code top bar height was fixed there to 56 + y: 56 + store: chatLayoutContainer.rootStore + chatSectionModule: chatLayoutContainer.rootStore.chatCommunitySectionModule + onClosed: { + Global.activityCenterPopupOpened = false + } + } + } + DropArea { id: dragTarget diff --git a/ui/imports/utils/Global.qml b/ui/imports/utils/Global.qml index 4d7b63a58a..3e1e900b66 100644 --- a/ui/imports/utils/Global.qml +++ b/ui/imports/utils/Global.qml @@ -19,6 +19,8 @@ QtObject { property var inviteFriendsToCommunityPopup property bool profilePopupOpened: false + property bool activityCenterPopupOpened: false + property var sendMessageSound property var notificationSound property var errorSound @@ -37,11 +39,16 @@ QtObject { signal openChangeProfilePicPopup() signal displayToastMessage(string title, string subTitle, string icon, bool loading, int ephNotifType, string url) signal openEditDisplayNamePopup() + signal openActivityCenterPopupRequested function openProfilePopup(publicKey, parentPopup, state = "") { openProfilePopupRequested(publicKey, parentPopup, state); } + function openActivityCenterPopup() { + openActivityCenterPopupRequested() + } + function openPopup(popupComponent, params = {}) { const popup = popupComponent.createObject(root.appMain, params); popup.open();