fix(chat): prevent reloading chat&community sections
Lazily load chat and community sections but do not unload them, otherwise all temporary data such as scroll position, text input, cursor position, etc., would vanish iterates: #10286
This commit is contained in:
parent
ec7bd963e9
commit
869c3937df
|
@ -2,7 +2,6 @@ import QtQuick 2.15
|
|||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Layouts 1.13
|
||||
import QtMultimedia 5.13
|
||||
import Qt.labs.qmlmodels 1.0
|
||||
import Qt.labs.platform 1.1
|
||||
import QtQml.Models 2.14
|
||||
import QtQml 2.15
|
||||
|
@ -843,7 +842,7 @@ Item {
|
|||
Loader {
|
||||
id: personalChatLayoutLoader
|
||||
asynchronous: true
|
||||
active: appView.currentIndex === Constants.appViewStackIndex.chat
|
||||
active: false
|
||||
sourceComponent: {
|
||||
if (appMain.rootStore.mainModuleInst.chatsLoadingFailed) {
|
||||
return errorStateComponent
|
||||
|
@ -854,6 +853,15 @@ Item {
|
|||
return loadingStateComponent
|
||||
}
|
||||
|
||||
// Do not unload section data from the memory in order not
|
||||
// to reset scroll, not send text input and etc during the
|
||||
// sections switching
|
||||
Binding on active {
|
||||
when: appView.currentIndex === Constants.appViewStackIndex.chat
|
||||
value: true
|
||||
restoreMode: Binding.RestoreNone
|
||||
}
|
||||
|
||||
Component {
|
||||
id: loadingStateComponent
|
||||
Item {
|
||||
|
@ -921,13 +929,6 @@ Item {
|
|||
onCreateCommunityClicked: {
|
||||
popups.openPopup(communitiesPortalLayoutContainer.createCommunitiesPopup);
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
// Do not unload section data from the memory in order not
|
||||
// to reset scroll, not send text input and etc during the
|
||||
// sections switching
|
||||
personalChatLayoutLoader.active = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -987,24 +988,35 @@ Item {
|
|||
}
|
||||
|
||||
Repeater {
|
||||
model: appMain.rootStore.mainModuleInst.sectionsModel
|
||||
|
||||
delegate: DelegateChooser {
|
||||
role: "sectionType"
|
||||
DelegateChoice {
|
||||
roleValue: Constants.appSection.community
|
||||
model: SortFilterProxyModel {
|
||||
sourceModel: appMain.rootStore.mainModuleInst.sectionsModel
|
||||
filters: ValueFilter {
|
||||
roleName: "sectionType"
|
||||
value: Constants.appSection.community
|
||||
}
|
||||
}
|
||||
|
||||
delegate: Loader {
|
||||
id: communityLoader
|
||||
readonly property string sectionId: model.id
|
||||
|
||||
asynchronous: true
|
||||
active: model.loaderActive
|
||||
readonly property string sectionId: model.id
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||
Layout.fillHeight: true
|
||||
|
||||
asynchronous: true
|
||||
active: false
|
||||
|
||||
// Do not unload section data from the memory in order not
|
||||
// to reset scroll, not send text input and etc during the
|
||||
// sections switching
|
||||
Binding on active {
|
||||
when: sectionId === appMain.rootStore.mainModuleInst.activeSection.id
|
||||
value: true
|
||||
restoreMode: Binding.RestoreNone
|
||||
}
|
||||
|
||||
sourceComponent: ChatLayout {
|
||||
id: chatLayoutComponent
|
||||
|
||||
|
@ -1042,8 +1054,6 @@ Item {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: createChatView
|
||||
|
|
Loading…
Reference in New Issue