From 3641dcbdc353ddbba00970a0c04e29bcd966cea9 Mon Sep 17 00:00:00 2001 From: vjrj Date: Fri, 10 Jul 2026 15:24:23 +0200 Subject: [PATCH] =?UTF-8?q?fix(block2):=20make=20DI=20idempotent=20?= =?UTF-8?q?=E2=80=94=20stop=20the=20app=20falling=20back=20to=20'inventory?= =?UTF-8?q?=20only'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- apps/app_seeds/lib/di/injector.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/app_seeds/lib/di/injector.dart b/apps/app_seeds/lib/di/injector.dart index 2cffc8d..4d45472 100644 --- a/apps/app_seeds/lib/di/injector.dart +++ b/apps/app_seeds/lib/di/injector.dart @@ -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 configureDependencies() async { + if (getIt.isRegistered()) return; + final secretStore = FlutterSecretStore(); final keyStore = SecureKeyStore(store: secretStore); final dbKeyHex = await keyStore.databaseKeyHex();