fix(mentions): fix wrong user list given to mentions model (#16656)

Fixes #16602

This was broken when we refactored the members to use a single model for public channels. Those public channels then didn't have any members in their model they used for suggestions.
This is fixed by putting the logic in the UsersStore and reusing that store whenever we need a list of the members.
This commit is contained in:
Jonathan Rainville 2024-10-30 15:02:46 -04:00 committed by GitHub
parent 0c86fbf7b6
commit 9e70e69faf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 26 additions and 13 deletions

View File

@ -3,9 +3,21 @@ import QtQuick 2.15
QtObject { QtObject {
id: root id: root
property var chatCommunitySectionModule
property var chatDetails
property var usersModule property var usersModule
readonly property var usersModel: usersModule ? usersModule.model : null readonly property var usersModel: {
if (!chatDetails && !chatCommunitySectionModule) {
return null
}
let isFullCommunityList = !chatDetails.requiresPermissions
if (chatDetails.belongsToCommunity && isFullCommunityList && !!chatCommunitySectionModule) {
// Community channel with no permisisons. We can use the section's membersModel
return chatCommunitySectionModule.membersModel
}
return usersModule ? usersModule.model : null
}
readonly property var temporaryModel: usersModule ? usersModule.temporaryModel : null readonly property var temporaryModel: usersModule ? usersModule.temporaryModel : null
function appendTemporaryModel(pubKey, displayName) { function appendTemporaryModel(pubKey, displayName) {

View File

@ -104,6 +104,8 @@ Item {
readonly property ChatStores.UsersStore activeUsersStore: ChatStores.UsersStore { readonly property ChatStores.UsersStore activeUsersStore: ChatStores.UsersStore {
usersModule: !!d.activeChatContentModule ? d.activeChatContentModule.usersModule : null usersModule: !!d.activeChatContentModule ? d.activeChatContentModule.usersModule : null
chatDetails: !!d.activeChatContentModule ? d.activeChatContentModule.chatDetails : null
chatCommunitySectionModule: root.rootStore.chatCommunitySectionModule
} }
readonly property ChatStores.MessageStore activeMessagesStore: ChatStores.MessageStore { readonly property ChatStores.MessageStore activeMessagesStore: ChatStores.MessageStore {

View File

@ -43,7 +43,9 @@ ColumnLayout {
property var emojiPopup property var emojiPopup
property var stickersPopup property var stickersPopup
property UsersStore usersStore: UsersStore {} property UsersStore usersStore: UsersStore {
chatCommunitySectionModule: root.rootStore.chatCommunitySectionModule
}
signal openStickerPackPopup(string stickerPackId) signal openStickerPackPopup(string stickerPackId)
@ -65,6 +67,7 @@ ColumnLayout {
spacing: 0 spacing: 0
onChatContentModuleChanged: if (!!chatContentModule) { onChatContentModuleChanged: if (!!chatContentModule) {
root.usersStore.chatDetails = root.chatContentModule.chatDetails
root.usersStore.usersModule = root.chatContentModule.usersModule root.usersStore.usersModule = root.chatContentModule.usersModule
} }

View File

@ -177,22 +177,18 @@ StatusSectionLayout {
rightPanel: Component { rightPanel: Component {
id: userListComponent id: userListComponent
UserListPanel { UserListPanel {
readonly property var usersStore: ChatStores.UsersStore {
usersModule: !!root.chatContentModule ? root.chatContentModule.usersModule : null
chatDetails: !!root.chatContentModule ? root.chatContentModule.chatDetails : null
chatCommunitySectionModule: root.rootStore.chatCommunitySectionModule
}
anchors.fill: parent anchors.fill: parent
store: root.rootStore store: root.rootStore
utilsStore: root.utilsStore utilsStore: root.utilsStore
label: qsTr("Members") label: qsTr("Members")
communityMemberReevaluationStatus: root.rootStore.communityMemberReevaluationStatus communityMemberReevaluationStatus: root.rootStore.communityMemberReevaluationStatus
usersModel: { usersModel: usersStore.usersModel
if (!root.chatContentModule || !root.chatContentModule.chatDetails) {
return null
}
let isFullCommunityList = !root.chatContentModule.chatDetails.requiresPermissions
if (root.chatContentModule.chatDetails.belongsToCommunity && isFullCommunityList) {
// Community channel with no permisisons. We can use the section's membersModel
return root.rootStore.chatCommunitySectionModule.membersModel
}
return root.chatContentModule.usersModule ? root.chatContentModule.usersModule.model : null
}
} }
} }