Skip to content

Commit e5b43df

Browse files
committed
messages [nfc]: Provide ChannelStore to MessageStore
This way, this substore becomes a valid home for methods that need to refer to data about both messages and channels. See also fab85ca, where we provided UserStore to ChannelStore.
1 parent f978e51 commit e5b43df

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/model/message.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ import '../api/model/model.dart';
1111
import '../api/route/messages.dart';
1212
import '../log.dart';
1313
import 'binding.dart';
14+
import 'channel.dart';
1415
import 'message_list.dart';
1516
import 'realm.dart';
1617
import 'store.dart';
1718

1819
const _apiSendMessage = sendMessage; // Bit ugly; for alternatives, see: https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/flutter.3A.20PerAccountStore.20methods/near/1545809
1920

2021
/// The portion of [PerAccountStore] for messages and message lists.
21-
mixin MessageStore {
22+
mixin MessageStore on ChannelStore {
2223
/// All known messages, indexed by [Message.id].
2324
Map<int, Message> get messages;
2425

@@ -138,8 +139,8 @@ class _EditMessageRequestStatus {
138139
final String newContent;
139140
}
140141

141-
class MessageStoreImpl extends HasRealmStore with MessageStore, _OutboxMessageStore {
142-
MessageStoreImpl({required super.realm})
142+
class MessageStoreImpl extends HasChannelStore with MessageStore, _OutboxMessageStore {
143+
MessageStoreImpl({required super.channels})
143144
: // There are no messages in InitialSnapshot, so we don't have
144145
// a use case for initializing MessageStore with nonempty [messages].
145146
messages = {};

lib/model/store.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ class PerAccountStore extends PerAccountStoreBase with
537537
presence: Presence(realm: realm,
538538
initial: initialSnapshot.presences),
539539
channels: channels,
540-
messages: MessageStoreImpl(realm: realm),
540+
messages: MessageStoreImpl(channels: channels),
541541
unreads: Unreads(core: core, channelStore: channels,
542542
initial: initialSnapshot.unreadMsgs),
543543
recentDmConversationsView: RecentDmConversationsView(core: core,

0 commit comments

Comments
 (0)