@@ -465,6 +465,7 @@ class PerAccountStore extends PerAccountStoreBase with ChangeNotifier, EmojiStor
465
465
accountId: accountId,
466
466
selfUserId: account.userId,
467
467
);
468
+ final mutedUserIdsSorted = _sortMutedUsers (initialSnapshot.mutedUsers);
468
469
final channels = ChannelStoreImpl (initialSnapshot: initialSnapshot);
469
470
return PerAccountStore ._(
470
471
core: core,
@@ -482,6 +483,7 @@ class PerAccountStore extends PerAccountStoreBase with ChangeNotifier, EmojiStor
482
483
core: core, allRealmEmoji: initialSnapshot.realmEmoji),
483
484
userSettings: initialSnapshot.userSettings,
484
485
mutedUsers: initialSnapshot.mutedUsers,
486
+ mutedUserIdsSorted: mutedUserIdsSorted,
485
487
typingNotifier: TypingNotifier (
486
488
core: core,
487
489
typingStoppedWaitPeriod: Duration (
@@ -501,7 +503,10 @@ class PerAccountStore extends PerAccountStoreBase with ChangeNotifier, EmojiStor
501
503
channelStore: channels,
502
504
),
503
505
recentDmConversationsView: RecentDmConversationsView (core: core,
504
- initial: initialSnapshot.recentPrivateConversations),
506
+ initial: _filterRecentPrivateConversations (
507
+ initialSnapshot.recentPrivateConversations,
508
+ mutedUserIdsSorted),
509
+ ),
505
510
recentSenders: RecentSenders (),
506
511
);
507
512
}
@@ -521,6 +526,7 @@ class PerAccountStore extends PerAccountStoreBase with ChangeNotifier, EmojiStor
521
526
required EmojiStoreImpl emoji,
522
527
required this .userSettings,
523
528
required this .mutedUsers,
529
+ required List <int > mutedUserIdsSorted,
524
530
required this .typingNotifier,
525
531
required UserStoreImpl users,
526
532
required this .typingStatus,
@@ -531,7 +537,7 @@ class PerAccountStore extends PerAccountStoreBase with ChangeNotifier, EmojiStor
531
537
required this .recentSenders,
532
538
}) : _realmEmptyTopicDisplayName = realmEmptyTopicDisplayName,
533
539
_emoji = emoji,
534
- _mutedUserIdsSorted = _sortMutedUsers (mutedUsers) ,
540
+ _mutedUserIdsSorted = mutedUserIdsSorted ,
535
541
_users = users,
536
542
_channels = channels,
537
543
_messages = messages;
@@ -946,6 +952,19 @@ class PerAccountStore extends PerAccountStoreBase with ChangeNotifier, EmojiStor
946
952
return mutedUsers.map ((user) => user.id).toList ()..sort ();
947
953
}
948
954
955
+ static List <RecentDmConversation > _filterRecentPrivateConversations (
956
+ List <RecentDmConversation > recentPms,
957
+ List <int > mutedUserIdsSorted,
958
+ ) {
959
+ bool isUserMuted (int id) =>
960
+ mutedUserIdsSorted.binarySearch (id, (a, b) => a.compareTo (b)) >= 0 ;
961
+
962
+ return recentPms
963
+ .where ((conversation) =>
964
+ conversation.userIds.any ((id) => ! isUserMuted (id)))
965
+ .toList ();
966
+ }
967
+
949
968
@override
950
969
String toString () => '${objectRuntimeType (this , 'PerAccountStore' )}#${shortHash (this )}' ;
951
970
}
0 commit comments