@@ -10,6 +10,7 @@ import '../log.dart';
10
10
import 'algorithms.dart' ;
11
11
import 'narrow.dart' ;
12
12
import 'channel.dart' ;
13
+ import 'store.dart' ;
13
14
14
15
/// The view-model for unread messages.
15
16
///
@@ -34,10 +35,10 @@ import 'channel.dart';
34
35
// sync to those unreads, because the user has shown an interest in them.
35
36
// TODO When loading a message list with stream messages, check all the stream
36
37
// messages and refresh [mentions] (see [mentions] dartdoc).
37
- class Unreads extends ChangeNotifier {
38
+ class Unreads extends PerAccountStoreBase with ChangeNotifier {
38
39
factory Unreads ({
39
40
required UnreadMessagesSnapshot initial,
40
- required int selfUserId ,
41
+ required CorePerAccountStore core ,
41
42
required ChannelStore channelStore,
42
43
}) {
43
44
final streams = < int , Map <TopicName , QueueList <int >>> {};
@@ -52,32 +53,33 @@ class Unreads extends ChangeNotifier {
52
53
53
54
for (final unreadDmSnapshot in initial.dms) {
54
55
final otherUserId = unreadDmSnapshot.otherUserId;
55
- final narrow = DmNarrow .withUser (otherUserId, selfUserId: selfUserId);
56
+ final narrow = DmNarrow .withUser (otherUserId, selfUserId: core. selfUserId);
56
57
dms[narrow] = QueueList .from (unreadDmSnapshot.unreadMessageIds);
57
58
}
58
59
59
60
for (final unreadHuddleSnapshot in initial.huddles) {
60
- final narrow = DmNarrow .ofUnreadHuddleSnapshot (unreadHuddleSnapshot, selfUserId: selfUserId);
61
+ final narrow = DmNarrow .ofUnreadHuddleSnapshot (unreadHuddleSnapshot,
62
+ selfUserId: core.selfUserId);
61
63
dms[narrow] = QueueList .from (unreadHuddleSnapshot.unreadMessageIds);
62
64
}
63
65
64
66
return Unreads ._(
67
+ core: core,
65
68
channelStore: channelStore,
66
69
streams: streams,
67
70
dms: dms,
68
71
mentions: mentions,
69
72
oldUnreadsMissing: initial.oldUnreadsMissing,
70
- selfUserId: selfUserId,
71
73
);
72
74
}
73
75
74
76
Unreads ._({
77
+ required super .core,
75
78
required this .channelStore,
76
79
required this .streams,
77
80
required this .dms,
78
81
required this .mentions,
79
82
required this .oldUnreadsMissing,
80
- required this .selfUserId,
81
83
});
82
84
83
85
final ChannelStore channelStore;
@@ -125,8 +127,6 @@ class Unreads extends ChangeNotifier {
125
127
/// Is set to false when the user clears out all unreads.
126
128
bool oldUnreadsMissing;
127
129
128
- final int selfUserId;
129
-
130
130
// TODO(#370): maintain this count incrementally, rather than recomputing from scratch
131
131
int countInCombinedFeedNarrow () {
132
132
int c = 0 ;
0 commit comments