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:
vjrj 2026-07-10 15:24:23 +02:00
parent 1ac954a09e
commit 3641dcbdc3

View file

@ -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();