fix(@desktop/sections): do not unload chat and communities sections during the switching between the sections
This commit is contained in:
parent
8ef495c604
commit
8d955265dc
|
@ -40,6 +40,8 @@ type
|
|||
BannedMembersModel
|
||||
Encrypted
|
||||
CommunityTokensModel
|
||||
DeclinedMemberRequestsModel
|
||||
AmIBanned
|
||||
|
||||
QtObject:
|
||||
type
|
||||
|
@ -109,6 +111,8 @@ QtObject:
|
|||
ModelRole.BannedMembersModel.int:"bannedMembers",
|
||||
ModelRole.Encrypted.int:"encrypted",
|
||||
ModelRole.CommunityTokensModel.int:"communityTokens",
|
||||
ModelRole.DeclinedMemberRequestsModel.int:"declinedMemberRequests",
|
||||
ModelRole.AmIBanned.int:"amIBanned"
|
||||
}.toTable
|
||||
|
||||
method data(self: SectionModel, index: QModelIndex, role: int): QVariant =
|
||||
|
@ -186,6 +190,10 @@ QtObject:
|
|||
result = newQVariant(item.encrypted)
|
||||
of ModelRole.CommunityTokensModel:
|
||||
result = newQVariant(item.communityTokens)
|
||||
of ModelRole.DeclinedMemberRequestsModel:
|
||||
result = newQVariant(item.declinedMemberRequests)
|
||||
of ModelRole.AmIBanned:
|
||||
result = newQVariant(item.amIBanned)
|
||||
|
||||
proc isItemExist(self: SectionModel, id: string): bool =
|
||||
for it in self.items:
|
||||
|
@ -278,7 +286,9 @@ QtObject:
|
|||
ModelRole.PinMessageAllMembersEnabled.int,
|
||||
ModelRole.BannedMembersModel.int,
|
||||
ModelRole.Encrypted.int,
|
||||
ModelRole.CommunityTokensModel.int
|
||||
ModelRole.CommunityTokensModel.int,
|
||||
ModelRole.DeclinedMemberRequestsModel.int,
|
||||
ModelRole.AmIBanned.int
|
||||
])
|
||||
|
||||
proc getNthEnabledItem*(self: SectionModel, nth: int): SectionItem =
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from scripts.global_names import *
|
||||
|
||||
# Main:
|
||||
mainWindow_communityColumnView_CommunityColumnView = {"container": statusDesktop_mainWindow, "objectName": "communityColumnView", "type": "CommunityColumnView"}
|
||||
mainWindow_communityColumnView_CommunityColumnView = {"container": statusDesktop_mainWindow, "objectName": "communityColumnView", "type": "CommunityColumnView", "visible": True}
|
||||
mainWindow_communityHeader_StatusChatInfoButton = {"container": statusDesktop_mainWindow, "objectName": "communityHeaderButton", "type": "StatusChatInfoButton", "visible": True}
|
||||
community_ChatInfo_Name_Text = {"container": mainWindow_communityHeader_StatusChatInfoButton, "objectName": "statusChatInfoButtonNameText", "type": "StatusBaseText", "visible": True}
|
||||
mainWindow_createChannelOrCategoryBtn_StatusBaseText = {"container": statusDesktop_mainWindow, "objectName": "createChannelOrCategoryBtn", "type": "StatusBaseText", "visible": True}
|
||||
|
|
|
@ -18,6 +18,8 @@ StackLayout {
|
|||
readonly property var contactsStore: rootStore.contactsStore
|
||||
readonly property var permissionsStore: rootStore.permissionsStore
|
||||
|
||||
property var sectionItemModel
|
||||
|
||||
property var emojiPopup
|
||||
property var stickersPopup
|
||||
signal importCommunityClicked()
|
||||
|
@ -34,7 +36,7 @@ StackLayout {
|
|||
MembershipRequestsPopup {
|
||||
anchors.centerIn: parent
|
||||
store: root.rootStore
|
||||
communityData: store.mainModuleInst ? store.mainModuleInst.activeSection || {} : {}
|
||||
communityData: sectionItemModel
|
||||
onClosed: {
|
||||
destroy()
|
||||
}
|
||||
|
@ -51,7 +53,7 @@ StackLayout {
|
|||
id: joinCommunityViewComponent
|
||||
JoinCommunityView {
|
||||
id: joinCommunityView
|
||||
readonly property var communityData: root.rootStore.mainModuleInst ? root.rootStore.mainModuleInst.activeSection || {} : {}
|
||||
readonly property var communityData: sectionItemModel
|
||||
name: communityData.name
|
||||
communityDesc: communityData.description
|
||||
color: communityData.color
|
||||
|
@ -94,6 +96,7 @@ StackLayout {
|
|||
stickersPopup: root.stickersPopup
|
||||
contactsStore: root.contactsStore
|
||||
rootStore: root.rootStore
|
||||
sectionItemModel: root.sectionItemModel
|
||||
membershipRequestPopup: membershipRequestPopupComponent
|
||||
|
||||
onCommunityInfoButtonClicked: root.currentIndex = 1
|
||||
|
@ -122,8 +125,7 @@ StackLayout {
|
|||
|
||||
hasAddedContacts: root.contactsStore.myContactsModel.count > 0
|
||||
chatCommunitySectionModule: root.rootStore.chatCommunitySectionModule
|
||||
community: root.rootStore.mainModuleInst ? root.rootStore.mainModuleInst.activeSection
|
||||
|| ({}) : ({})
|
||||
community: sectionItemModel
|
||||
|
||||
onBackToCommunityClicked: root.currentIndex = 0
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ StatusSectionLayout {
|
|||
property bool hasAddedContacts: root.contactsStore.myContactsModel.count > 0
|
||||
|
||||
property RootStore rootStore
|
||||
property var sectionItemModel
|
||||
|
||||
property Component membershipRequestPopup
|
||||
property var emojiPopup
|
||||
|
@ -156,6 +157,7 @@ StatusSectionLayout {
|
|||
id: communtiyColumnComponent
|
||||
CommunityColumnView {
|
||||
communitySectionModule: root.rootStore.chatCommunitySectionModule
|
||||
communityData: sectionItemModel
|
||||
store: root.rootStore
|
||||
emojiPopup: root.emojiPopup
|
||||
hasAddedContacts: root.hasAddedContacts
|
||||
|
|
|
@ -32,7 +32,7 @@ Item {
|
|||
|
||||
property var store
|
||||
property bool hasAddedContacts: false
|
||||
property var communityData: store.mainModuleInst ? store.mainModuleInst.activeSection || ({}) : ({})
|
||||
property var communityData
|
||||
property Component membershipRequestPopup
|
||||
|
||||
signal infoButtonClicked
|
||||
|
|
|
@ -42,8 +42,8 @@ StatusSectionLayout {
|
|||
// {name: qsTr("Token sales"), icon: "token-sale"},
|
||||
// {name: qsTr("Subscriptions"), icon: "subscription"},
|
||||
property var rootStore
|
||||
property var community
|
||||
property var chatCommunitySectionModule
|
||||
property var community
|
||||
property bool hasAddedContacts: false
|
||||
property var transactionStore: TransactionStore {}
|
||||
|
||||
|
@ -231,7 +231,7 @@ StatusSectionLayout {
|
|||
CommunityMembersSettingsPanel {
|
||||
membersModel: root.community.members
|
||||
bannedMembersModel: root.community.bannedMembers
|
||||
pendingMemberRequestsModel: root.community.pendingMemberRequests
|
||||
pendingMemberRequestsModel: root.community.pendingRequestsToJoin
|
||||
declinedMemberRequestsModel: root.community.declinedMemberRequests
|
||||
editable: root.community.amISectionAdmin
|
||||
communityName: root.community.name
|
||||
|
|
|
@ -778,7 +778,12 @@ Item {
|
|||
restoreMode: Binding.RestoreBindingOrValue
|
||||
}
|
||||
|
||||
rootStore: appMain.rootChatStore
|
||||
rootStore: ChatStores.RootStore {
|
||||
contactsStore: appMain.rootStore.contactStore
|
||||
emojiReactionsModel: appMain.rootStore.emojiReactionsModel
|
||||
openCreateChat: createChatView.opened
|
||||
chatCommunitySectionModule: appMain.rootStore.mainModuleInst.getChatSectionModule()
|
||||
}
|
||||
emojiPopup: statusEmojiPopup
|
||||
stickersPopup: statusStickersPopupLoader.item
|
||||
|
||||
|
@ -799,7 +804,10 @@ Item {
|
|||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
rootStore.chatCommunitySectionModule = appMain.rootStore.mainModuleInst.getChatSectionModule()
|
||||
// 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -866,9 +874,12 @@ Item {
|
|||
roleValue: Constants.appSection.community
|
||||
|
||||
delegate: Loader {
|
||||
id: communityLoader
|
||||
readonly property string sectionId: model.id
|
||||
active: sectionId === appMain.rootStore.mainModuleInst.activeSection.id
|
||||
|
||||
asynchronous: true
|
||||
active: sectionId === appMain.rootStore.mainModuleInst.activeSection.id
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||
Layout.fillHeight: true
|
||||
|
@ -886,8 +897,17 @@ Item {
|
|||
|
||||
emojiPopup: statusEmojiPopup
|
||||
stickersPopup: statusStickersPopupLoader.item
|
||||
sectionItemModel: model
|
||||
|
||||
rootStore: appMain.rootChatStore
|
||||
rootStore: ChatStores.RootStore {
|
||||
contactsStore: appMain.rootStore.contactStore
|
||||
emojiReactionsModel: appMain.rootStore.emojiReactionsModel
|
||||
openCreateChat: createChatView.opened
|
||||
chatCommunitySectionModule: {
|
||||
appMain.rootStore.mainModuleInst.prepareCommunitySectionModuleForCommunityId(model.id)
|
||||
return appMain.rootStore.mainModuleInst.getCommunitySectionModule()
|
||||
}
|
||||
}
|
||||
|
||||
onProfileButtonClicked: {
|
||||
Global.changeAppSectionBySectionType(Constants.appSection.profile);
|
||||
|
@ -898,10 +918,10 @@ Item {
|
|||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
// we cannot return QVariant if we pass another parameter in a function call
|
||||
// that's why we're using it this way
|
||||
appMain.rootStore.mainModuleInst.prepareCommunitySectionModuleForCommunityId(model.id)
|
||||
rootStore.chatCommunitySectionModule = appMain.rootStore.mainModuleInst.getCommunitySectionModule()
|
||||
// Do not unload section data from the memory in order not
|
||||
// to reset scroll, not send text input and etc during the
|
||||
// sections switching
|
||||
communityLoader.active = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -927,7 +947,13 @@ Item {
|
|||
anchors.rightMargin - anchors.leftMargin : 0
|
||||
|
||||
sourceComponent: CreateChatView {
|
||||
rootStore: appMain.rootChatStore
|
||||
rootStore: ChatStores.RootStore {
|
||||
contactsStore: appMain.rootStore.contactStore
|
||||
emojiReactionsModel: appMain.rootStore.emojiReactionsModel
|
||||
openCreateChat: createChatView.opened
|
||||
chatCommunitySectionModule: appMain.rootStore.mainModuleInst.getChatSectionModule()
|
||||
|
||||
}
|
||||
emojiPopup: statusEmojiPopup
|
||||
stickersPopup: statusStickersPopupLoader.item
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue