@@ -328,6 +328,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
328
328
assert (connection.zulipFeatureLevel == account.zulipFeatureLevel);
329
329
330
330
final realmUrl = account.realmUrl;
331
+ final mutedUserIdsSorted = _sortMutedUsers (initialSnapshot.mutedUsers);
331
332
final channels = ChannelStoreImpl (initialSnapshot: initialSnapshot);
332
333
return PerAccountStore ._(
333
334
globalStore: globalStore,
@@ -346,6 +347,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
346
347
accountId: accountId,
347
348
userSettings: initialSnapshot.userSettings,
348
349
mutedUsers: initialSnapshot.mutedUsers,
350
+ mutedUserIdsSorted: mutedUserIdsSorted,
349
351
typingNotifier: TypingNotifier (
350
352
connection: connection,
351
353
typingStoppedWaitPeriod: Duration (
@@ -368,7 +370,11 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
368
370
channelStore: channels,
369
371
),
370
372
recentDmConversationsView: RecentDmConversationsView (
371
- initial: initialSnapshot.recentPrivateConversations, selfUserId: account.userId),
373
+ initial: _filterRecentPrivateConversations (
374
+ initialSnapshot.recentPrivateConversations,
375
+ mutedUserIdsSorted),
376
+ selfUserId: account.userId,
377
+ ),
372
378
recentSenders: RecentSenders (),
373
379
);
374
380
}
@@ -389,6 +395,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
389
395
required this .accountId,
390
396
required this .userSettings,
391
397
required this .mutedUsers,
398
+ required List <int > mutedUserIdsSorted,
392
399
required this .typingNotifier,
393
400
required UserStoreImpl users,
394
401
required this .typingStatus,
@@ -403,7 +410,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
403
410
_globalStore = globalStore,
404
411
_realmEmptyTopicDisplayName = realmEmptyTopicDisplayName,
405
412
_emoji = emoji,
406
- _mutedUserIdsSorted = _sortMutedUsers (mutedUsers) ,
413
+ _mutedUserIdsSorted = mutedUserIdsSorted ,
407
414
_users = users,
408
415
_channels = channels,
409
416
_messages = messages;
@@ -837,6 +844,19 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
837
844
return mutedUsers.map ((user) => user.id).toList ()..sort ();
838
845
}
839
846
847
+ static List <RecentDmConversation > _filterRecentPrivateConversations (
848
+ List <RecentDmConversation > recentPms,
849
+ List <int > mutedUserIdsSorted,
850
+ ) {
851
+ bool isUserMuted (int id) =>
852
+ mutedUserIdsSorted.binarySearch (id, (a, b) => a.compareTo (b)) >= 0 ;
853
+
854
+ return recentPms
855
+ .where ((conversation) =>
856
+ conversation.userIds.any ((id) => ! isUserMuted (id)))
857
+ .toList ();
858
+ }
859
+
840
860
@override
841
861
String toString () => '${objectRuntimeType (this , 'PerAccountStore' )}#${shortHash (this )}' ;
842
862
}
0 commit comments