@@ -8,6 +8,7 @@ import '../api/model/model.dart';
8
8
import '../api/model/events.dart' ;
9
9
import 'narrow.dart' ;
10
10
import 'store.dart' ;
11
+ import 'user.dart' ;
11
12
12
13
/// A view-model for the recent-DM-conversations UI.
13
14
///
@@ -17,6 +18,7 @@ class RecentDmConversationsView extends PerAccountStoreBase with ChangeNotifier
17
18
factory RecentDmConversationsView ({
18
19
required CorePerAccountStore core,
19
20
required List <RecentDmConversation > initial,
21
+ required UserStore userStore,
20
22
}) {
21
23
final entries = initial.map ((conversation) => MapEntry (
22
24
DmNarrow .ofRecentDmConversation (conversation, selfUserId: core.selfUserId),
@@ -35,6 +37,7 @@ class RecentDmConversationsView extends PerAccountStoreBase with ChangeNotifier
35
37
36
38
return RecentDmConversationsView ._(
37
39
core: core,
40
+ userStore: userStore,
38
41
map: Map .fromEntries (entries),
39
42
sorted: QueueList .from (entries.map ((e) => e.key)),
40
43
latestMessagesByRecipient: latestMessagesByRecipient,
@@ -43,11 +46,14 @@ class RecentDmConversationsView extends PerAccountStoreBase with ChangeNotifier
43
46
44
47
RecentDmConversationsView ._({
45
48
required super .core,
49
+ required this .userStore,
46
50
required this .map,
47
51
required this .sorted,
48
52
required this .latestMessagesByRecipient,
49
53
});
50
54
55
+ final UserStore userStore;
56
+
51
57
/// The latest message ID in each conversation.
52
58
final Map <DmNarrow , int > map;
53
59
@@ -63,6 +69,11 @@ class RecentDmConversationsView extends PerAccountStoreBase with ChangeNotifier
63
69
/// it might have been sent by anyone in its conversation.)
64
70
final Map <int , int > latestMessagesByRecipient;
65
71
72
+ /// Same as [sorted] but excluding conversations where all the recipients are
73
+ /// muted.
74
+ QueueList <DmNarrow > get sortedFiltered => QueueList .from (
75
+ sorted.whereNot ((narrow) => userStore.allRecipientsMuted (narrow)));
76
+
66
77
/// Insert the key at the proper place in [sorted] .
67
78
///
68
79
/// Optimized, taking O(1) time, for the case where that place is the start,
0 commit comments