fix(CreateChatView): Move `ActivityCenterPopup` to appmain

Closes: #6345
This commit is contained in:
Boris Melnik 2022-07-26 17:23:45 +03:00
parent 210d5ca2eb
commit fbc10e7665
8 changed files with 77 additions and 62 deletions

View File

@ -8,12 +8,16 @@ import StatusQ.Controls 0.1
import shared 1.0 import shared 1.0
import shared.popups 1.0 import shared.popups 1.0
import shared.views.chat 1.0
import utils 1.0 import utils 1.0
import "../views" import "../views"
import "../panels" import "../panels"
Popup { Popup {
id: root
enum Filter { enum Filter {
All, All,
Mentions, Mentions,
@ -28,11 +32,13 @@ Popup {
property bool hideReadNotifications: false property bool hideReadNotifications: false
property var store property var store
property var chatSectionModule 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 modal: false
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
@ -55,7 +61,7 @@ Popup {
color: Style.current.dropShadow color: Style.current.dropShadow
} }
} }
x: Global.applicationWindow.width - activityCenter.width - Style.current.halfPadding x: Global.applicationWindow.width - root.width - Style.current.halfPadding
onOpened: { onOpened: {
Global.popupOpened = true Global.popupOpened = true
} }
@ -66,27 +72,27 @@ Popup {
ActivityCenterPopupTopBarPanel { ActivityCenterPopupTopBarPanel {
id: activityCenterTopBar id: activityCenterTopBar
hasReplies: activityCenter.hasReplies hasReplies: root.hasReplies
hasMentions: activityCenter.hasMentions hasMentions: root.hasMentions
hideReadNotifications: activityCenter.hideReadNotifications hideReadNotifications: root.hideReadNotifications
allBtnHighlighted: activityCenter.currentFilter === ActivityCenterPopup.Filter.All allBtnHighlighted: root.currentFilter === ActivityCenterPopup.Filter.All
mentionsBtnHighlighted: activityCenter.currentFilter === ActivityCenterPopup.Filter.Mentions mentionsBtnHighlighted: root.currentFilter === ActivityCenterPopup.Filter.Mentions
repliesBtnHighlighted: activityCenter.currentFilter === ActivityCenterPopup.Filter.Replies repliesBtnHighlighted: root.currentFilter === ActivityCenterPopup.Filter.Replies
onAllBtnClicked: { onAllBtnClicked: {
activityCenter.currentFilter = ActivityCenterPopup.Filter.All; root.currentFilter = ActivityCenterPopup.Filter.All;
} }
onRepliesBtnClicked: { onRepliesBtnClicked: {
activityCenter.currentFilter = ActivityCenterPopup.Filter.Replies; root.currentFilter = ActivityCenterPopup.Filter.Replies;
} }
onMentionsBtnClicked: { onMentionsBtnClicked: {
activityCenter.currentFilter = ActivityCenterPopup.Filter.Mentions; root.currentFilter = ActivityCenterPopup.Filter.Mentions;
} }
onPreferencesClicked: { onPreferencesClicked: {
activityCenter.close() root.close()
Global.changeAppSectionBySectionType(Constants.appSection.profile, Constants.settingsSubsection.notifications); Global.changeAppSectionBySectionType(Constants.appSection.profile, Constants.settingsSubsection.notifications);
} }
onMarkAllReadClicked: { 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 // TODO remove this once it is handled by the activity center
// Repeater { // Repeater {
// id: contactList // id: contactList
// model: activityCenter.store.contactRequests // model: root.store.contactRequests
// delegate: ContactRequest { // delegate: ContactRequest {
// visible: !hideReadNotifications && // 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) // name: Utils.removeStatusEns(model.name)
// address: model.address // address: model.address
// localNickname: model.localNickname // localNickname: model.localNickname
@ -142,7 +148,7 @@ Popup {
function(left, right) { return left.timestamp > right.timestamp } function(left, right) { return left.timestamp > right.timestamp }
] ]
model: activityCenter.store.activityCenterList model: root.store.activityCenterList
delegate: Item { delegate: Item {
id: notificationDelegate id: notificationDelegate
@ -180,9 +186,9 @@ Popup {
} }
return -1; 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: { onPreviousNotificationTimestampChanged: {
activityCenter.store.messageStore.prevMsgTimestamp = previousNotificationTimestamp; root.store.messageStore.prevMsgTimestamp = previousNotificationTimestamp;
} }
id: notifLoader id: notifLoader
@ -212,17 +218,17 @@ Popup {
ActivityCenterMessageComponentView { ActivityCenterMessageComponentView {
id: activityCenterMessageView id: activityCenterMessageView
store: activityCenter.store store: root.store
acCurrentFilter: activityCenter.currentFilter acCurrentFilter: root.currentFilter
chatSectionModule: activityCenter.chatSectionModule chatSectionModule: root.chatSectionModule
messageContextMenu: activityCenter.messageContextMenu messageContextMenu: root.messageContextMenu
hideReadNotifications: activityCenter.hideReadNotifications hideReadNotifications: root.hideReadNotifications
Connections { Connections {
target: activityCenter target: root
onOpened: activityCenterMessageView.reevaluateItemBadge() onOpened: activityCenterMessageView.reevaluateItemBadge()
} }
onActivityCenterClose: { onActivityCenterClose: {
activityCenter.close(); root.close();
} }
Component.onCompleted: { Component.onCompleted: {
activityCenterMessageView.reevaluateItemBadge() activityCenterMessageView.reevaluateItemBadge()
@ -234,16 +240,16 @@ Popup {
id: groupRequestNotificationComponent id: groupRequestNotificationComponent
ActivityCenterGroupRequest { ActivityCenterGroupRequest {
store: activityCenter.store store: root.store
hideReadNotifications: activityCenter.hideReadNotifications hideReadNotifications: root.hideReadNotifications
acCurrentFilterAll: activityCenter.currentFilter === ActivityCenter.Filter.All acCurrentFilterAll: root.currentFilter === ActivityCenter.Filter.All
} }
} }
} }
} }
Item { Item {
visible: activityCenter.store.activityCenterModuleInst.hasMoreToShow visible: root.store.activityCenterModuleInst.hasMoreToShow
width: parent.width width: parent.width
height: visible ? showMoreBtn.height + showMoreBtn.anchors.topMargin : 0 height: visible ? showMoreBtn.height + showMoreBtn.anchors.topMargin : 0
StatusButton { StatusButton {
@ -252,7 +258,7 @@ Popup {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: Style.current.smallPadding anchors.topMargin: Style.current.smallPadding
onClicked: activityCenter.store.activityCenterModuleInst.loadMoreNotifications() onClicked: root.store.activityCenterModuleInst.loadMoreNotifications()
} }
} }
} }

View File

@ -2,3 +2,4 @@ PinnedMessagesPopup 1.0 PinnedMessagesPopup.qml
ChooseBrowserPopup 1.0 ChooseBrowserPopup.qml ChooseBrowserPopup 1.0 ChooseBrowserPopup.qml
InviteFriendsToCommunityPopup 1.0 community/InviteFriendsToCommunityPopup.qml InviteFriendsToCommunityPopup 1.0 community/InviteFriendsToCommunityPopup.qml
CommunityProfilePopup 1.0 community/CommunityProfilePopup.qml CommunityProfilePopup 1.0 community/CommunityProfilePopup.qml
ActivityCenterPopup 1.0 ActivityCenterPopup.qml

View File

@ -122,6 +122,7 @@ QtObject {
property var mainModuleInst: mainModule property var mainModuleInst: mainModule
property var activityCenterModuleInst: activityCenterModule property var activityCenterModuleInst: activityCenterModule
property var activityCenterList: activityCenterModuleInst.model property var activityCenterList: activityCenterModuleInst.model
property int unreadNotificationsCount: activityCenterList.unreadCount
property var communitiesModuleInst: communitiesModule property var communitiesModuleInst: communitiesModule
property var communitiesList: communitiesModuleInst.model property var communitiesList: communitiesModuleInst.model

View File

@ -58,8 +58,6 @@ Item {
property bool contactRequestReceived: root.contactDetails.requestReceived property bool contactRequestReceived: root.contactDetails.requestReceived
property Component pinnedMessagesListPopupComponent property Component pinnedMessagesListPopupComponent
property alias activityCenter: activityCenter
signal openAppSearch() signal openAppSearch()
signal openStickerPackPopup(string stickerPackId) signal openStickerPackPopup(string stickerPackId)
@ -155,12 +153,6 @@ Item {
} }
} }
MessageContextMenuView {
id: contextmenu
store: root.rootStore
reactionModel: root.rootStore.emojiReactionsModel
}
EmptyChatPanel { EmptyChatPanel {
anchors.fill: parent anchors.fill: parent
visible: root.activeChatId === "" || root.chatsCount == 0 visible: root.activeChatId === "" || root.chatsCount == 0
@ -233,14 +225,14 @@ Item {
stickersLoaded: root.stickersLoaded stickersLoaded: root.stickersLoaded
isBlocked: model.blocked isBlocked: model.blocked
isActiveChannel: categoryChatLoader.isActiveChannel isActiveChannel: categoryChatLoader.isActiveChannel
activityCenterVisible: activityCenter.visible activityCenterVisible: Global.activityCenterPopupOpened
activityCenterNotificationsCount: activityCenter.unreadNotificationsCount activityCenterNotificationsCount: root.rootStore.unreadNotificationsCount
pinnedMessagesPopupComponent: root.pinnedMessagesListPopupComponent pinnedMessagesPopupComponent: root.pinnedMessagesListPopupComponent
onOpenStickerPackPopup: { onOpenStickerPackPopup: {
root.openStickerPackPopup(stickerPackId) root.openStickerPackPopup(stickerPackId)
} }
onNotificationButtonClicked: { onNotificationButtonClicked: {
activityCenter.open(); Global.openActivityCenterPopup()
} }
onOpenAppSearch: { onOpenAppSearch: {
root.openAppSearch(); root.openAppSearch();
@ -264,13 +256,13 @@ Item {
width: parent.width width: parent.width
height: isActiveChannel ? parent.height : 0 height: isActiveChannel ? parent.height : 0
Connections { Connections {
id: loaderConnections id: defaultLoaderConnections
target: chatLoader target: chatLoader
// First time this channel turns active, activate the Loader // First time this channel turns active, activate the Loader
onIsActiveChannelChanged: { onIsActiveChannelChanged: {
if (chatLoader.isActiveChannel) { if (chatLoader.isActiveChannel) {
chatLoader.active = true chatLoader.active = true
loaderConnections.enabled = false defaultLoaderConnections.enabled = false
} }
} }
} }
@ -290,14 +282,14 @@ Item {
stickersLoaded: root.stickersLoaded stickersLoaded: root.stickersLoaded
isBlocked: model.blocked isBlocked: model.blocked
isActiveChannel: chatLoader.isActiveChannel isActiveChannel: chatLoader.isActiveChannel
activityCenterVisible: activityCenter.visible activityCenterVisible: Global.activityCenterPopupOpened
activityCenterNotificationsCount: activityCenter.unreadNotificationsCount activityCenterNotificationsCount: root.rootStore.unreadNotificationsCount
pinnedMessagesPopupComponent: root.pinnedMessagesListPopupComponent pinnedMessagesPopupComponent: root.pinnedMessagesListPopupComponent
onOpenStickerPackPopup: { onOpenStickerPackPopup: {
root.openStickerPackPopup(stickerPackId) root.openStickerPackPopup(stickerPackId)
} }
onNotificationButtonClicked: { onNotificationButtonClicked: {
activityCenter.open(); Global.openActivityCenterPopup()
} }
onOpenAppSearch: { onOpenAppSearch: {
root.openAppSearch(); 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 // Not Refactored Yet
// Connections { // Connections {
// target: root.rootStore.chatsModelInst.stickers // target: root.rootStore.chatsModelInst.stickers

View File

@ -25,7 +25,6 @@ StatusAppThreePanelLayout {
property var contactsStore property var contactsStore
property bool hasAddedContacts: root.contactsStore.myContactsModel.count > 0 property bool hasAddedContacts: root.contactsStore.myContactsModel.count > 0
property alias activityCenter: chatColumn.activityCenter
property RootStore rootStore property RootStore rootStore

View File

@ -18,7 +18,6 @@ Page {
property ListModel contactsModel: ListModel { } property ListModel contactsModel: ListModel { }
property var rootStore property var rootStore
property var activityCenter: null
property var emojiPopup: null property var emojiPopup: null
Keys.onEscapePressed: Global.closeCreateChatView() Keys.onEscapePressed: Global.closeCreateChatView()
@ -135,8 +134,8 @@ Page {
width: parent.width width: parent.width
height: parent.height height: parent.height
tooltip.offset: width/2 tooltip.offset: width/2
unreadNotificationsCount: activityCenter.unreadNotificationsCount unreadNotificationsCount: root.rootStore.unreadNotificationsCount
onClicked: activityCenter.open() onClicked: Global.openActivityCenterPopup()
} }
} }
} }

View File

@ -89,6 +89,12 @@ Item {
popup.openPopup(publicKey, state); popup.openPopup(publicKey, state);
Global.profilePopupOpened = true; Global.profilePopupOpened = true;
} }
onOpenActivityCenterPopupRequested: {
Global.openPopup(activityCenterPopupComponent)
Global.activityCenterPopupOpened = true
}
onOpenChangeProfilePicPopup: { onOpenChangeProfilePicPopup: {
var popup = changeProfilePicComponent.createObject(appMain); var popup = changeProfilePicComponent.createObject(appMain);
popup.chooseImageToCrop(); popup.chooseImageToCrop();
@ -651,7 +657,6 @@ Item {
property bool opened: false property bool opened: false
rootStore: chatLayoutContainer.rootStore rootStore: chatLayoutContainer.rootStore
activityCenter: chatLayoutContainer.chatView.activityCenter
emojiPopup: statusEmojiPopup emojiPopup: statusEmojiPopup
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: 8 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 { DropArea {
id: dragTarget id: dragTarget

View File

@ -19,6 +19,8 @@ QtObject {
property var inviteFriendsToCommunityPopup property var inviteFriendsToCommunityPopup
property bool profilePopupOpened: false property bool profilePopupOpened: false
property bool activityCenterPopupOpened: false
property var sendMessageSound property var sendMessageSound
property var notificationSound property var notificationSound
property var errorSound property var errorSound
@ -37,11 +39,16 @@ QtObject {
signal openChangeProfilePicPopup() signal openChangeProfilePicPopup()
signal displayToastMessage(string title, string subTitle, string icon, bool loading, int ephNotifType, string url) signal displayToastMessage(string title, string subTitle, string icon, bool loading, int ephNotifType, string url)
signal openEditDisplayNamePopup() signal openEditDisplayNamePopup()
signal openActivityCenterPopupRequested
function openProfilePopup(publicKey, parentPopup, state = "") { function openProfilePopup(publicKey, parentPopup, state = "") {
openProfilePopupRequested(publicKey, parentPopup, state); openProfilePopupRequested(publicKey, parentPopup, state);
} }
function openActivityCenterPopup() {
openActivityCenterPopupRequested()
}
function openPopup(popupComponent, params = {}) { function openPopup(popupComponent, params = {}) {
const popup = popupComponent.createObject(root.appMain, params); const popup = popupComponent.createObject(root.appMain, params);
popup.open(); popup.open();