@@ -327,6 +327,24 @@ abstract class GlobalStore extends ChangeNotifier {
327327
328328class AccountNotFoundException implements Exception {}
329329
330+ /// A bundle of items that are useful to [PerAccountStore] and its substores.
331+ class CorePerAccountStore {
332+ CorePerAccountStore ({required this .connection});
333+
334+ final ApiConnection connection; // TODO(#135): update zulipFeatureLevel with events
335+ }
336+
337+ /// A base class for [PerAccountStore] and its substores,
338+ /// with getters providing the items in [CorePerAccountStore] .
339+ abstract class PerAccountStoreBase {
340+ PerAccountStoreBase ({required CorePerAccountStore core})
341+ : _core = core;
342+
343+ final CorePerAccountStore _core;
344+
345+ ApiConnection get connection => _core.connection;
346+ }
347+
330348/// Store for the user's data for a given Zulip account.
331349///
332350/// This should always have a consistent snapshot of the state on the server,
@@ -335,7 +353,7 @@ class AccountNotFoundException implements Exception {}
335353/// This class does not attempt to poll an event queue
336354/// to keep the data up to date. For that behavior, see
337355/// [UpdateMachine] .
338- class PerAccountStore extends ChangeNotifier with EmojiStore , UserStore , ChannelStore , MessageStore {
356+ class PerAccountStore extends PerAccountStoreBase with ChangeNotifier , EmojiStore , UserStore , ChannelStore , MessageStore {
339357 /// Construct a store for the user's data, starting from the given snapshot.
340358 ///
341359 /// The global store must already have been updated with
@@ -368,10 +386,11 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
368386 }
369387
370388 final realmUrl = account.realmUrl;
389+ final core = CorePerAccountStore (connection: connection);
371390 final channels = ChannelStoreImpl (initialSnapshot: initialSnapshot);
372391 return PerAccountStore ._(
373392 globalStore: globalStore,
374- connection : connection ,
393+ core : core ,
375394 queueId: queueId,
376395 realmUrl: realmUrl,
377396 realmWildcardMentionPolicy: initialSnapshot.realmWildcardMentionPolicy,
@@ -401,7 +420,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
401420 typingStartedExpiryPeriod: Duration (milliseconds: initialSnapshot.serverTypingStartedExpiryPeriodMilliseconds),
402421 ),
403422 channels: channels,
404- messages: MessageStoreImpl (connection : connection ),
423+ messages: MessageStoreImpl (core : core ),
405424 unreads: Unreads (
406425 initial: initialSnapshot.unreadMsgs,
407426 selfUserId: account.userId,
@@ -415,7 +434,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
415434
416435 PerAccountStore ._({
417436 required GlobalStore globalStore,
418- required this .connection ,
437+ required super .core ,
419438 required this .queueId,
420439 required this .realmUrl,
421440 required this .realmWildcardMentionPolicy,
@@ -438,7 +457,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
438457 required this .recentDmConversationsView,
439458 required this .recentSenders,
440459 }) : assert (realmUrl == globalStore.getAccount (accountId)! .realmUrl),
441- assert (realmUrl == connection.realmUrl),
460+ assert (realmUrl == core. connection.realmUrl),
442461 assert (emoji.realmUrl == realmUrl),
443462 _globalStore = globalStore,
444463 _realmEmptyTopicDisplayName = realmEmptyTopicDisplayName,
@@ -454,7 +473,6 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
454473 // Where data comes from in the first place.
455474
456475 final GlobalStore _globalStore;
457- final ApiConnection connection; // TODO(#135): update zulipFeatureLevel with events
458476
459477 final String queueId;
460478 UpdateMachine ? get updateMachine => _updateMachine;
0 commit comments