Skip to content

Commit 5233cfb

Browse files
committed
user [nfc]: Move proxy boilerplate out to substore file
1 parent 9a5960a commit 5233cfb

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

lib/model/store.dart

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ class PerAccountStore extends PerAccountStoreBase with
441441
RealmStore, ProxyRealmStore,
442442
EmojiStore, ProxyEmojiStore,
443443
SavedSnippetStore,
444-
UserStore,
444+
UserStore, ProxyUserStore,
445445
ChannelStore,
446446
MessageStore {
447447
/// Construct a store for the user's data, starting from the given snapshot.
@@ -595,23 +595,9 @@ class PerAccountStore extends PerAccountStoreBase with
595595
//|//////////////////////////////
596596
// Users and data about them.
597597

598+
@protected
598599
@override
599-
User? getUser(int userId) => _users.getUser(userId);
600-
601-
@override
602-
Iterable<User> get allUsers => _users.allUsers;
603-
604-
@override
605-
bool isUserMuted(int userId, {MutedUsersEvent? event}) =>
606-
_users.isUserMuted(userId, event: event);
607-
608-
@override
609-
MutedUsersVisibilityEffect mightChangeShouldMuteDmConversation(MutedUsersEvent event) =>
610-
_users.mightChangeShouldMuteDmConversation(event);
611-
612-
@override
613-
UserStatus getUserStatus(int userId) => _users.getUserStatus(userId);
614-
600+
UserStore get userStore => _users;
615601
final UserStoreImpl _users;
616602

617603
final TypingStatus typingStatus;

lib/model/user.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'package:flutter/foundation.dart';
2+
13
import '../api/model/events.dart';
24
import '../api/model/initial_snapshot.dart';
35
import '../api/model/model.dart';
@@ -179,6 +181,28 @@ enum MutedUsersVisibilityEffect {
179181
mixed;
180182
}
181183

184+
mixin ProxyUserStore on UserStore {
185+
@protected
186+
UserStore get userStore;
187+
188+
@override
189+
User? getUser(int userId) => userStore.getUser(userId);
190+
191+
@override
192+
Iterable<User> get allUsers => userStore.allUsers;
193+
194+
@override
195+
bool isUserMuted(int userId, {MutedUsersEvent? event}) =>
196+
userStore.isUserMuted(userId, event: event);
197+
198+
@override
199+
MutedUsersVisibilityEffect mightChangeShouldMuteDmConversation(MutedUsersEvent event) =>
200+
userStore.mightChangeShouldMuteDmConversation(event);
201+
202+
@override
203+
UserStatus getUserStatus(int userId) => userStore.getUserStatus(userId);
204+
}
205+
182206
/// The implementation of [UserStore] that does the work.
183207
///
184208
/// Generally the only code that should need this class is [PerAccountStore]

0 commit comments

Comments
 (0)