Skip to content

Commit c14feb3

Browse files
committed
store: Exclude DM conversations with muted users
1 parent 013f216 commit c14feb3

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lib/model/store.dart

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,11 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
368368
channelStore: channels,
369369
),
370370
recentDmConversationsView: RecentDmConversationsView(
371-
initial: initialSnapshot.recentPrivateConversations, selfUserId: account.userId),
371+
initial: _filterRecentPrivateConversations(
372+
initialSnapshot.recentPrivateConversations,
373+
initialSnapshot.mutedUsers),
374+
selfUserId: account.userId,
375+
),
372376
recentSenders: RecentSenders(),
373377
);
374378
}
@@ -837,6 +841,17 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
837841
return mutedUsers.map((user) => user.id).toList()..sort();
838842
}
839843

844+
static List<RecentDmConversation> _filterRecentPrivateConversations(
845+
List<RecentDmConversation> recentPms,
846+
List<MutedUserItem> mutedUsers,
847+
) {
848+
final mutedUserIds = {for (var user in mutedUsers) user.id};
849+
return recentPms
850+
.where((conversation) =>
851+
conversation.userIds.any((id) => !mutedUserIds.contains(id)))
852+
.toList();
853+
}
854+
840855
@override
841856
String toString() => '${objectRuntimeType(this, 'PerAccountStore')}#${shortHash(this)}';
842857
}

0 commit comments

Comments
 (0)