@@ -327,6 +327,24 @@ abstract class GlobalStore extends ChangeNotifier {
327
327
328
328
class AccountNotFoundException implements Exception {}
329
329
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
+
330
348
/// Store for the user's data for a given Zulip account.
331
349
///
332
350
/// This should always have a consistent snapshot of the state on the server,
@@ -335,7 +353,7 @@ class AccountNotFoundException implements Exception {}
335
353
/// This class does not attempt to poll an event queue
336
354
/// to keep the data up to date. For that behavior, see
337
355
/// [UpdateMachine] .
338
- class PerAccountStore extends ChangeNotifier with EmojiStore , UserStore , ChannelStore , MessageStore {
356
+ class PerAccountStore extends PerAccountStoreBase with ChangeNotifier , EmojiStore , UserStore , ChannelStore , MessageStore {
339
357
/// Construct a store for the user's data, starting from the given snapshot.
340
358
///
341
359
/// The global store must already have been updated with
@@ -368,10 +386,11 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
368
386
}
369
387
370
388
final realmUrl = account.realmUrl;
389
+ final core = CorePerAccountStore (connection: connection);
371
390
final channels = ChannelStoreImpl (initialSnapshot: initialSnapshot);
372
391
return PerAccountStore ._(
373
392
globalStore: globalStore,
374
- connection : connection ,
393
+ core : core ,
375
394
queueId: queueId,
376
395
realmUrl: realmUrl,
377
396
realmWildcardMentionPolicy: initialSnapshot.realmWildcardMentionPolicy,
@@ -401,7 +420,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
401
420
typingStartedExpiryPeriod: Duration (milliseconds: initialSnapshot.serverTypingStartedExpiryPeriodMilliseconds),
402
421
),
403
422
channels: channels,
404
- messages: MessageStoreImpl (connection : connection ),
423
+ messages: MessageStoreImpl (core : core ),
405
424
unreads: Unreads (
406
425
initial: initialSnapshot.unreadMsgs,
407
426
selfUserId: account.userId,
@@ -415,7 +434,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
415
434
416
435
PerAccountStore ._({
417
436
required GlobalStore globalStore,
418
- required this .connection ,
437
+ required super .core ,
419
438
required this .queueId,
420
439
required this .realmUrl,
421
440
required this .realmWildcardMentionPolicy,
@@ -438,7 +457,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
438
457
required this .recentDmConversationsView,
439
458
required this .recentSenders,
440
459
}) : assert (realmUrl == globalStore.getAccount (accountId)! .realmUrl),
441
- assert (realmUrl == connection.realmUrl),
460
+ assert (realmUrl == core. connection.realmUrl),
442
461
assert (emoji.realmUrl == realmUrl),
443
462
_globalStore = globalStore,
444
463
_realmEmptyTopicDisplayName = realmEmptyTopicDisplayName,
@@ -454,7 +473,6 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
454
473
// Where data comes from in the first place.
455
474
456
475
final GlobalStore _globalStore;
457
- final ApiConnection connection; // TODO(#135): update zulipFeatureLevel with events
458
476
459
477
final String queueId;
460
478
UpdateMachine ? get updateMachine => _updateMachine;
0 commit comments