Skip to content

Commit 18914a4

Browse files
committed
store [nfc]: Add indirection doLoadPerAccount
1 parent 325c663 commit 18914a4

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
@@ -144,7 +144,14 @@ abstract class GlobalStore extends ChangeNotifier {
144144
/// This method should be called only by the implementation of [perAccount].
145145
/// Other callers interested in per-account data should use [perAccount]
146146
/// and/or [perAccountSync].
147-
Future<PerAccountStore> loadPerAccount(int accountId);
147+
Future<PerAccountStore> loadPerAccount(int accountId) {
148+
return doLoadPerAccount(accountId);
149+
}
150+
151+
/// Load per-account data for the given account, unconditionally.
152+
///
153+
/// This method should be called only by [loadPerAccount].
154+
Future<PerAccountStore> doLoadPerAccount(int accountId);
148155

149156
// Just the Iterables, not the actual Map, to avoid clients mutating the map.
150157
// Mutations should go through the setters/mutators below.
@@ -682,7 +689,7 @@ class LiveGlobalStore extends GlobalStore {
682689
final AppDatabase _db;
683690

684691
@override
685-
Future<PerAccountStore> loadPerAccount(int accountId) async {
692+
Future<PerAccountStore> doLoadPerAccount(int accountId) async {
686693
final updateMachine = await UpdateMachine.load(this, accountId);
687694
return updateMachine.store;
688695
}

test/model/store_test.dart

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

672672
@override
673-
Future<PerAccountStore> loadPerAccount(int accountId) {
673+
Future<PerAccountStore> doLoadPerAccount(int accountId) {
674674
final completer = Completer<PerAccountStore>();
675675
(completers[accountId] ??= []).add(completer);
676676
return completer.future;

test/model/test_store.dart

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

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

0 commit comments

Comments
 (0)