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

View File

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