fix(chat): use proper section details data

It prevents `StatusChatInput::enabled` property to be changed when
switching sections, as a consequence the text is persisted.

fixes: #10286
This commit is contained in:
Patryk Osmaczko 2023-04-18 11:11:47 +02:00 committed by osmaczko
parent 9a7699b52f
commit 36063f33f1
2 changed files with 24 additions and 6 deletions

View File

@ -33,9 +33,10 @@ QtObject {
// Each `ChatLayout` has its own chatCommunitySectionModule
// (on the backend chat and community sections share the same module since they are actually the same)
property var chatCommunitySectionModule
readonly property var sectionDetails: _d.sectionDetailsInstantiator.count ? _d.sectionDetailsInstantiator.objectAt(0) : null
property var communityItemsModel: chatCommunitySectionModule.model
property var assetsModel: SortFilterProxyModel {
sourceModel: chatCommunitySectionModule.tokenList
@ -658,4 +659,24 @@ QtObject {
root.goToMembershipRequestsPage()
}
}
readonly property QtObject _d: QtObject {
readonly property var sectionDetailsInstantiator: Instantiator {
model: SortFilterProxyModel {
sourceModel: mainModuleInst.sectionsModel
filters: ValueFilter {
roleName: "id"
value: chatCommunitySectionModule.getMySectionId()
}
}
delegate: QtObject {
readonly property string id: model.id
readonly property int sectionType: model.sectionType
readonly property string name: model.name
readonly property bool joined: model.joined
readonly property bool amIBanned: model.amIBanned
// add others when needed..
}
}
}
}

View File

@ -58,9 +58,6 @@ ColumnLayout {
property bool stickersLoaded: false
// FIXME: this should be section data related only to that view, not the active one
readonly property var activeSectionData: rootStore.mainModuleInst ? rootStore.mainModuleInst.activeSection || {} : {}
onIsActiveChannelChanged: {
if (isActiveChannel) {
chatInput.forceInputActiveFocus();
@ -183,7 +180,7 @@ ColumnLayout {
anchors.fill: parent
anchors.margins: Style.current.smallPadding
enabled: root.activeSectionData.joined && !root.activeSectionData.amIBanned &&
enabled: root.rootStore.sectionDetails.joined && !root.rootStore.sectionDetails.amIBanned &&
!(chatType === Constants.chatType.oneToOne && !root.isUserAdded)
store: root.rootStore
@ -204,7 +201,7 @@ ColumnLayout {
}
Binding on chatInputPlaceholder {
when: !root.activeSectionData.joined || root.activeSectionData.amIBanned
when: !root.rootStore.sectionDetails.joined || root.rootStore.sectionDetails.amIBanned
value: qsTr("You need to join this community to send messages")
}