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.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()
}
}
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

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

View File

@ -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()
}
}
}

View File

@ -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

View File

@ -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();