Skip to content

Commit d09a31d

Browse files
committed
store [nfc]: Add indirection doLoadPerAccount
1 parent bb419c1 commit d09a31d

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

lib/model/store.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,14 @@ abstract class GlobalStore extends ChangeNotifier {
142142
/// This method should be called only by the implementation of [perAccount].
143143
/// Other callers interested in per-account data should use [perAccount]
144144
/// and/or [perAccountSync].
145-
Future<PerAccountStore> loadPerAccount(int accountId);
145+
Future<PerAccountStore> loadPerAccount(int accountId) {
146+
return doLoadPerAccount(accountId);
147+
}
148+
149+
/// Load per-account data for the given account, unconditionally.
150+
///
151+
/// This method should be called only by [loadPerAccount].
152+
Future<PerAccountStore> doLoadPerAccount(int accountId);
146153

147154
// Just the Iterables, not the actual Map, to avoid clients mutating the map.
148155
// Mutations should go through the setters/mutators below.
@@ -650,7 +657,7 @@ class LiveGlobalStore extends GlobalStore {
650657
final AppDatabase _db;
651658

652659
@override
653-
Future<PerAccountStore> loadPerAccount(int accountId) async {
660+
Future<PerAccountStore> doLoadPerAccount(int accountId) async {
654661
final updateMachine = await UpdateMachine.load(this, accountId);
655662
return updateMachine.store;
656663
}

test/model/store_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ class LoadingTestGlobalStore extends TestGlobalStore {
603603
Map<int, List<Completer<PerAccountStore>>> completers = {};
604604

605605
@override
606-
Future<PerAccountStore> loadPerAccount(int accountId) {
606+
Future<PerAccountStore> doLoadPerAccount(int accountId) {
607607
final completer = Completer<PerAccountStore>();
608608
(completers[accountId] ??= []).add(completer);
609609
return completer.future;

test/model/test_store.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class TestGlobalStore extends GlobalStore {
106106
}
107107

108108
@override
109-
Future<PerAccountStore> loadPerAccount(int accountId) {
109+
Future<PerAccountStore> doLoadPerAccount(int accountId) {
110110
final initialSnapshot = _initialSnapshots[accountId]!;
111111
final store = PerAccountStore.fromInitialSnapshot(
112112
globalStore: this,

0 commit comments

Comments
 (0)