Skip to content

Commit 0a2273c

Browse files
committed
store [nfc]: Make account-exists assumption explicit in some dartdocs
In particular: GlobalStore.loadPerAccount GlobalStore.doLoadPerAccount UpdateMachine.load The first two already have an `assert` that the account exists, and the third has a ! null-check. They're called in a chain from two places, and we have the account in both: the initial account load and the reload (GlobalStore._reloadPerAccount).
1 parent 228c9bd commit 0a2273c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/model/store.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ abstract class GlobalStore extends ChangeNotifier {
170170

171171
/// Load per-account data for the given account, unconditionally.
172172
///
173+
/// The account for `accountId` must exist.
174+
///
173175
/// This method should be called only by the implementation of [perAccount].
174176
/// Other callers interested in per-account data should use [perAccount]
175177
/// and/or [perAccountSync].
@@ -214,6 +216,8 @@ abstract class GlobalStore extends ChangeNotifier {
214216

215217
/// Load per-account data for the given account, unconditionally.
216218
///
219+
/// The account for `accountId` must exist.
220+
///
217221
/// This method should be called only by [loadPerAccount].
218222
Future<PerAccountStore> doLoadPerAccount(int accountId);
219223

@@ -264,6 +268,8 @@ abstract class GlobalStore extends ChangeNotifier {
264268
Future<void> doUpdateAccount(int accountId, AccountsCompanion data);
265269

266270
/// Remove an account from the store.
271+
///
272+
/// The account for `accountId` must exist.
267273
Future<void> removeAccount(int accountId) async {
268274
assert(_accounts.containsKey(accountId));
269275
await doRemoveAccount(accountId);
@@ -942,7 +948,10 @@ class UpdateMachine {
942948
store.updateMachine = this;
943949
}
944950

945-
/// Load the user's data from the server, and start an event queue going.
951+
/// Load data for the given account from the server,
952+
/// and start an event queue going.
953+
///
954+
/// The account for `accountId` must exist.
946955
///
947956
/// In the future this might load an old snapshot from local storage first.
948957
static Future<UpdateMachine> load(GlobalStore globalStore, int accountId) async {

0 commit comments

Comments
 (0)