fix: pasting a user's profile link in the ad-hoc chat search

... doesn't work in the community section

Extract the `Chat.RootStore` as a toplevel/shared property and pass it
down to ChatLayouts, instead of cross referencing it between different
components. This was also problematic since the ChatLayouts now live
inside a Loader, so it's more appropriate to refer to the
`Chat.RootStore` directly, instead of
`personalChatLayoutLoader.item.rootStore`, since the
`personalChatLayoutLoader.item` might not be visible (due to it being
inside a Loader and a StackLayout) or it might even be a different
component (`loadingStateComponent` or `errorStateComponent`).

This also caused similar problems for other components, such as
ActivityCenterPopup or StatusStickersPopup.

Fixes #9513
This commit is contained in:
Lukáš Tinkl 2023-02-09 22:49:36 +01:00 committed by Lukáš Tinkl
parent 2bc8fa1236
commit eafee302d8
3 changed files with 16 additions and 15 deletions

View File

@ -11,10 +11,8 @@ import "popups/community"
StackLayout { StackLayout {
id: root id: root
property var contactsStore property RootStore rootStore
property RootStore rootStore: RootStore { readonly property var contactsStore: rootStore.contactsStore
contactsStore: root.contactsStore
}
property alias chatView: chatView property alias chatView: chatView
signal importCommunityClicked() signal importCommunityClicked()

View File

@ -1,4 +1,5 @@
StickerData 1.0 StickerData.qml StickerData 1.0 StickerData.qml
StickerPackData 1.0 StickerPackData.qml StickerPackData 1.0 StickerPackData.qml
StickersStore 1.0 StickersStore.qml StickersStore 1.0 StickersStore.qml
CommunitiesStore 1.0 CommunitiesStore.qml CommunitiesStore 1.0 CommunitiesStore.qml
RootStore 1.0 RootStore.qml

View File

@ -32,6 +32,7 @@ import StatusQ.Core 0.1
import AppLayouts.Browser.stores 1.0 as BrowserStores import AppLayouts.Browser.stores 1.0 as BrowserStores
import AppLayouts.stores 1.0 import AppLayouts.stores 1.0
import AppLayouts.Chat.stores 1.0 as ChatStores
import SortFilterProxyModel 0.2 import SortFilterProxyModel 0.2
@ -44,6 +45,11 @@ Item {
property alias appLayout: appLayout property alias appLayout: appLayout
property RootStore rootStore: RootStore {} property RootStore rootStore: RootStore {}
property var rootChatStore: ChatStores.RootStore {
contactsStore: appMain.rootStore.contactStore
emojiReactionsModel: appMain.rootStore.emojiReactionsModel
openCreateChat: createChatView.opened
}
property ActivityCenterStore activityCenterStore: ActivityCenterStore {} property ActivityCenterStore activityCenterStore: ActivityCenterStore {}
// set from main.qml // set from main.qml
property var sysPalette property var sysPalette
@ -215,7 +221,7 @@ Item {
active: appMain.rootStore.mainModuleInst.chatsLoaded active: appMain.rootStore.mainModuleInst.chatsLoaded
sourceComponent: StatusStickersPopup { sourceComponent: StatusStickersPopup {
id: statusStickersPopup id: statusStickersPopup
store: personalChatLayoutLoader.item.rootStore store: appMain.rootChatStore
} }
} }
@ -755,13 +761,11 @@ Item {
ChatLayout { ChatLayout {
id: chatLayoutContainer id: chatLayoutContainer
rootStore: appMain.rootChatStore
chatView.emojiPopup: statusEmojiPopup chatView.emojiPopup: statusEmojiPopup
chatView.stickersPopup: statusStickersPopupLoader.item chatView.stickersPopup: statusStickersPopupLoader.item
contactsStore: appMain.rootStore.contactStore
rootStore.emojiReactionsModel: appMain.rootStore.emojiReactionsModel
rootStore.openCreateChat: createChatView.opened
chatView.onProfileButtonClicked: { chatView.onProfileButtonClicked: {
Global.changeAppSectionBySectionType(Constants.appSection.profile); Global.changeAppSectionBySectionType(Constants.appSection.profile);
} }
@ -857,9 +861,7 @@ Item {
chatView.emojiPopup: statusEmojiPopup chatView.emojiPopup: statusEmojiPopup
chatView.stickersPopup: statusStickersPopupLoader.item chatView.stickersPopup: statusStickersPopupLoader.item
contactsStore: appMain.rootStore.contactStore rootStore: appMain.rootChatStore
rootStore.emojiReactionsModel: appMain.rootStore.emojiReactionsModel
rootStore.openCreateChat: createChatView.opened
chatView.onProfileButtonClicked: { chatView.onProfileButtonClicked: {
Global.changeAppSectionBySectionType(Constants.appSection.profile); Global.changeAppSectionBySectionType(Constants.appSection.profile);
@ -899,7 +901,7 @@ Item {
anchors.rightMargin - anchors.leftMargin : 0 anchors.rightMargin - anchors.leftMargin : 0
sourceComponent: CreateChatView { sourceComponent: CreateChatView {
rootStore: personalChatLayoutLoader.item.rootStore rootStore: appMain.rootChatStore
emojiPopup: statusEmojiPopup emojiPopup: statusEmojiPopup
stickersPopup: statusStickersPopupLoader.item stickersPopup: statusStickersPopupLoader.item
} }
@ -916,7 +918,7 @@ Item {
x: parent.width - width - Style.current.smallPadding x: parent.width - width - Style.current.smallPadding
y: parent.y + _buttonSize y: parent.y + _buttonSize
height: appView.height - _buttonSize * 2 height: appView.height - _buttonSize * 2
store: personalChatLayoutLoader.item.rootStore store: appMain.rootChatStore
activityCenterStore: appMain.activityCenterStore activityCenterStore: appMain.activityCenterStore
} }
} }