Skip to content

Commit

Permalink
fix(mentions): fix wrong user list given to mentions model
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jrainville committed Oct 29, 2024
1 parent e64877c commit 4e0d6e9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
14 changes: 13 additions & 1 deletion ui/app/AppLayouts/Chat/stores/UsersStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@ import QtQuick 2.15
QtObject {
id: root

property var chatCommunitySectionModule
property var chatDetails
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

function appendTemporaryModel(pubKey, displayName) {
Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Chat/views/ChatColumnView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ Item {

readonly property ChatStores.UsersStore activeUsersStore: ChatStores.UsersStore {
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 {
Expand Down
5 changes: 4 additions & 1 deletion ui/app/AppLayouts/Chat/views/ChatContentView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ ColumnLayout {

property var emojiPopup
property var stickersPopup
property UsersStore usersStore: UsersStore {}
property UsersStore usersStore: UsersStore {
chatCommunitySectionModule: root.rootStore.chatCommunitySectionModule
}

signal openStickerPackPopup(string stickerPackId)

Expand All @@ -63,6 +65,7 @@ ColumnLayout {
spacing: 0

onChatContentModuleChanged: if (!!chatContentModule) {
root.usersStore.chatDetails = root.chatContentModule.chatDetails
root.usersStore.usersModule = root.chatContentModule.usersModule
}

Expand Down
18 changes: 7 additions & 11 deletions ui/app/AppLayouts/Chat/views/ChatView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,17 @@ StatusSectionLayout {
rightPanel: Component {
id: userListComponent
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
store: root.rootStore
label: qsTr("Members")
communityMemberReevaluationStatus: root.rootStore.communityMemberReevaluationStatus
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
}
usersModel: usersStore.usersModel
}
}

Expand Down

0 comments on commit 4e0d6e9

Please sign in to comment.