fix(block2): make DI idempotent — stop the app falling back to 'inventory only'
Feedback: at times the social items showed greyed ('like phase 1'), only
inventory active. Cause: a hot restart / Android Activity restart re-runs main
while GetIt still holds the singletons; re-registration threw, main aborted
before rebuilding TaneApp with the social layer, leaving the pre-Block-2 tree.
configureDependencies now returns early if already configured, so re-entry
succeeds and TaneApp is always built with the social layer wired.
This commit is contained in:
parent
3fe5397675
commit
3e84e9bb3f
1 changed files with 7 additions and 0 deletions
|
|
@ -41,7 +41,14 @@ final GetIt getIt = GetIt.instance;
|
|||
|
||||
/// Wires the encrypted DB, keystore and repositories. Call once from `main`
|
||||
/// before `runApp`; the DB key must exist before the DB opens.
|
||||
///
|
||||
/// Idempotent: a hot restart (or an Android Activity restart that keeps the
|
||||
/// isolate) re-runs `main` while GetIt still holds the singletons. Without this
|
||||
/// guard the re-registration throws, `main` aborts before rebuilding `TaneApp`
|
||||
/// with the social layer, and the app falls back to the "inventory only" look.
|
||||
Future<void> configureDependencies() async {
|
||||
if (getIt.isRegistered<SocialService>()) return;
|
||||
|
||||
final secretStore = FlutterSecretStore();
|
||||
final keyStore = SecureKeyStore(store: secretStore);
|
||||
final dbKeyHex = await keyStore.databaseKeyHex();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue