fix(chat): use loader for ChatMessagesView instead ChatContentView

fixes: #10285
This commit is contained in:
Patryk Osmaczko 2023-04-17 22:43:23 +02:00 committed by osmaczko
parent 136635670e
commit ec7bd963e9
2 changed files with 54 additions and 58 deletions

View File

@ -135,17 +135,11 @@ Item {
id: chatRepeater id: chatRepeater
model: parentModule && parentModule.model model: parentModule && parentModule.model
delegate: Loader { ChatContentView {
id: chatLoader
// Channels/chats are not loaded by default and only load when first put active
active: model.loaderActive
width: parent.width width: parent.width
height: parent.height height: parent.height
visible: model.active visible: model.active && !root.rootStore.openCreateChat && isActiveChannel
chatMessagesLoader.active: model.loaderActive
sourceComponent: ChatContentView {
visible: !root.rootStore.openCreateChat && isActiveChannel
rootStore: root.rootStore rootStore: root.rootStore
contactsStore: root.contactsStore contactsStore: root.contactsStore
emojiPopup: root.emojiPopup emojiPopup: root.emojiPopup
@ -156,7 +150,7 @@ Item {
stickersLoaded: root.stickersLoaded stickersLoaded: root.stickersLoaded
isBlocked: model.blocked isBlocked: model.blocked
isUserAdded: root.isUserAdded isUserAdded: root.isUserAdded
isActiveChannel: chatLoader.visible isActiveChannel: model.active
onOpenStickerPackPopup: { onOpenStickerPackPopup: {
root.openStickerPackPopup(stickerPackId) root.openStickerPackPopup(stickerPackId)
} }
@ -171,7 +165,6 @@ Item {
} }
} }
} }
}
ChatRequestMessagePanel { ChatRequestMessagePanel {
anchors.fill: parent anchors.fill: parent

View File

@ -36,9 +36,10 @@ ColumnLayout {
property var contactsStore property var contactsStore
property bool isActiveChannel: false property bool isActiveChannel: false
readonly property alias chatMessagesLoader: chatMessagesLoader
property var emojiPopup property var emojiPopup
property var stickersPopup property var stickersPopup
property alias textInputField: chatInput
property UsersStore usersStore: UsersStore {} property UsersStore usersStore: UsersStore {}
onChatContentModuleChanged: { onChatContentModuleChanged: {
@ -76,8 +77,7 @@ ColumnLayout {
} }
} }
MessageStore { readonly property var messageStore: MessageStore {
id: messageStore
messageModule: chatContentModule ? chatContentModule.messagesModule : null messageModule: chatContentModule ? chatContentModule.messagesModule : null
chatSectionModule: root.rootStore.chatCommunitySectionModule chatSectionModule: root.rootStore.chatCommunitySectionModule
} }
@ -137,15 +137,17 @@ ColumnLayout {
Layout.fillHeight: true Layout.fillHeight: true
clip: true clip: true
ChatMessagesView { Loader {
id: chatMessages id: chatMessagesLoader
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
sourceComponent: ChatMessagesView {
chatContentModule: root.chatContentModule chatContentModule: root.chatContentModule
rootStore: root.rootStore rootStore: root.rootStore
contactsStore: root.contactsStore contactsStore: root.contactsStore
messageContextMenu: contextmenu messageContextMenu: contextmenu
messageStore: messageStore messageStore: root.messageStore
emojiPopup: root.emojiPopup emojiPopup: root.emojiPopup
stickersPopup: root.stickersPopup stickersPopup: root.stickersPopup
usersStore: root.usersStore usersStore: root.usersStore
@ -165,6 +167,7 @@ ColumnLayout {
} }
onEditModeChanged: if (!editModeOn) chatInput.forceInputActiveFocus() onEditModeChanged: if (!editModeOn) chatInput.forceInputActiveFocus()
} }
}
Item { Item {
id: inputArea id: inputArea