Skip to content

Commit fea9e01

Browse files
committed
realm [nfc]: Add HasRealmStore for other substores to use
The other substores could always handle this themselves individually, like Unreads does today with ChannelStore. But this is one substore that lots of others are going to want references to, so we might as well make that a bit easier.
1 parent a2fa946 commit fea9e01

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/model/realm.dart

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import 'store.dart';
1010
///
1111
/// See also:
1212
/// * [RealmStoreImpl] for the implementation of this that does the work.
13-
mixin RealmStore {
13+
/// * [HasRealmStore] for an implementation useful for other substores.
14+
mixin RealmStore on PerAccountStoreBase {
1415
int get serverPresencePingIntervalSeconds;
1516
int get serverPresenceOfflineThresholdSeconds;
1617

@@ -68,6 +69,17 @@ mixin ProxyRealmStore on RealmStore {
6869
EmailAddressVisibility? get emailAddressVisibility => realmStore.emailAddressVisibility;
6970
}
7071

72+
/// A base class for [PerAccountStore] substores that need access to [RealmStore]
73+
/// as well as to [CorePerAccountStore].
74+
abstract class HasRealmStore extends PerAccountStoreBase with RealmStore, ProxyRealmStore {
75+
HasRealmStore({required RealmStore realm})
76+
: realmStore = realm, super(core: realm.core);
77+
78+
@protected
79+
@override
80+
final RealmStore realmStore;
81+
}
82+
7183
/// The implementation of [RealmStore] that does the work.
7284
class RealmStoreImpl extends PerAccountStoreBase with RealmStore {
7385
RealmStoreImpl({

0 commit comments

Comments
 (0)