Skip to content

Commit 082cd11

Browse files
committed
store [nfc]: Move accountId to PerAccountStoreBase
1 parent eba689b commit 082cd11

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib/model/store.dart

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,12 @@ class CorePerAccountStore {
338338
CorePerAccountStore._({
339339
required GlobalStore globalStore,
340340
required this.connection,
341+
required this.accountId,
341342
}) : _globalStore = globalStore;
342343

343344
final GlobalStore _globalStore;
344345
final ApiConnection connection; // TODO(#135): update zulipFeatureLevel with events
346+
final int accountId;
345347
}
346348

347349
/// A base class for [PerAccountStore] and its substores,
@@ -352,9 +354,17 @@ abstract class PerAccountStoreBase {
352354

353355
final CorePerAccountStore _core;
354356

357+
////////////////////////////////
358+
// Where data comes from in the first place.
359+
355360
GlobalStore get _globalStore => _core._globalStore;
356361

357362
ApiConnection get connection => _core.connection;
363+
364+
////////////////////////////////
365+
// Data attached to the self-account on the realm.
366+
367+
int get accountId => _core.accountId;
358368
}
359369

360370
/// Store for the user's data for a given Zulip account.
@@ -401,6 +411,7 @@ class PerAccountStore extends PerAccountStoreBase with ChangeNotifier, EmojiStor
401411
final core = CorePerAccountStore._(
402412
globalStore: globalStore,
403413
connection: connection,
414+
accountId: accountId,
404415
);
405416
final channels = ChannelStoreImpl(initialSnapshot: initialSnapshot);
406417
return PerAccountStore._(
@@ -418,7 +429,6 @@ class PerAccountStore extends PerAccountStoreBase with ChangeNotifier, EmojiStor
418429
emailAddressVisibility: initialSnapshot.emailAddressVisibility,
419430
emoji: EmojiStoreImpl(
420431
realmUrl: realmUrl, allRealmEmoji: initialSnapshot.realmEmoji),
421-
accountId: accountId,
422432
userSettings: initialSnapshot.userSettings,
423433
typingNotifier: TypingNotifier(
424434
core: core,
@@ -461,7 +471,6 @@ class PerAccountStore extends PerAccountStoreBase with ChangeNotifier, EmojiStor
461471
required this.customProfileFields,
462472
required this.emailAddressVisibility,
463473
required EmojiStoreImpl emoji,
464-
required this.accountId,
465474
required this.userSettings,
466475
required this.typingNotifier,
467476
required UserStoreImpl users,
@@ -471,7 +480,7 @@ class PerAccountStore extends PerAccountStoreBase with ChangeNotifier, EmojiStor
471480
required this.unreads,
472481
required this.recentDmConversationsView,
473482
required this.recentSenders,
474-
}) : assert(realmUrl == globalStore.getAccount(accountId)!.realmUrl),
483+
}) : assert(realmUrl == globalStore.getAccount(core.accountId)!.realmUrl),
475484
assert(realmUrl == core.connection.realmUrl),
476485
assert(emoji.realmUrl == realmUrl),
477486
_realmEmptyTopicDisplayName = realmEmptyTopicDisplayName,
@@ -572,8 +581,6 @@ class PerAccountStore extends PerAccountStoreBase with ChangeNotifier, EmojiStor
572581
////////////////////////////////
573582
// Data attached to the self-account on the realm.
574583

575-
final int accountId;
576-
577584
/// The [Account] this store belongs to.
578585
///
579586
/// Will throw if the account has been removed from the global store,

0 commit comments

Comments
 (0)