Skip to content

Commit 72cf5d6

Browse files
committed
channel [nfc]: Move proxy boilerplate out to substore file
1 parent 6b47ff0 commit 72cf5d6

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

lib/model/channel.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,28 @@ enum UserTopicVisibilityEffect {
186186
}
187187
}
188188

189+
mixin ProxyChannelStore on ChannelStore {
190+
@protected
191+
ChannelStore get channelStore;
192+
193+
@override
194+
Map<int, ZulipStream> get streams => channelStore.streams;
195+
196+
@override
197+
Map<String, ZulipStream> get streamsByName => channelStore.streamsByName;
198+
199+
@override
200+
Map<int, Subscription> get subscriptions => channelStore.subscriptions;
201+
202+
@override
203+
UserTopicVisibilityPolicy topicVisibilityPolicy(int streamId, TopicName topic) =>
204+
channelStore.topicVisibilityPolicy(streamId, topic);
205+
206+
@override
207+
Map<int, Map<TopicName, UserTopicVisibilityPolicy>> get debugTopicVisibility =>
208+
channelStore.debugTopicVisibility;
209+
}
210+
189211
/// The implementation of [ChannelStore] that does the work.
190212
///
191213
/// Generally the only code that should need this class is [PerAccountStore]

lib/model/store.dart

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ class PerAccountStore extends PerAccountStoreBase with
442442
EmojiStore, ProxyEmojiStore,
443443
SavedSnippetStore,
444444
UserStore, ProxyUserStore,
445-
ChannelStore,
445+
ChannelStore, ProxyChannelStore,
446446
MessageStore {
447447
/// Construct a store for the user's data, starting from the given snapshot.
448448
///
@@ -609,19 +609,9 @@ class PerAccountStore extends PerAccountStoreBase with
609609
//|//////////////////////////////
610610
// Streams, topics, and stuff about them.
611611

612+
@protected
612613
@override
613-
Map<int, ZulipStream> get streams => _channels.streams;
614-
@override
615-
Map<String, ZulipStream> get streamsByName => _channels.streamsByName;
616-
@override
617-
Map<int, Subscription> get subscriptions => _channels.subscriptions;
618-
@override
619-
UserTopicVisibilityPolicy topicVisibilityPolicy(int streamId, TopicName topic) =>
620-
_channels.topicVisibilityPolicy(streamId, topic);
621-
@override
622-
Map<int, Map<TopicName, UserTopicVisibilityPolicy>> get debugTopicVisibility =>
623-
_channels.debugTopicVisibility;
624-
614+
ChannelStore get channelStore => _channels;
625615
final ChannelStoreImpl _channels;
626616

627617
//|//////////////////////////////

0 commit comments

Comments
 (0)