fix(di): robust all-or-nothing init so the social layer never greys out

The idempotency guard used SocialService as its sentinel, but that was
registered mid-cascade, so a run that crashed part-way could leave a
half-built container the next run would reuse (or hit 'already
registered' on) — intermittently falling back to the inventory-only look
with market/chat/profile greyed out.

- Guard on a dedicated _DepsReady marker registered LAST, so the sentinel
  means the WHOLE container is wired, never a partial one.
- Reset a half-wired container (crashed prior run) before rebuilding,
  instead of reusing it. Safe: main aborts before runApp on a partial run.
- Make the social key derivation non-fatal: on failure the app opens on
  inventory (social hidden) rather than blanking. main tolerates an
  absent SocialService.
This commit is contained in:
vjrj 2026-07-10 16:12:49 +02:00
parent 97b9223cb2
commit 606861bbfa
2 changed files with 46 additions and 9 deletions

View file

@ -32,7 +32,9 @@ Future<void> main() async {
repository: getIt<VarietyRepository>(),
species: getIt<SpeciesRepository>(),
onboarding: onboarding,
social: getIt<SocialService>(),
social: getIt.isRegistered<SocialService>()
? getIt<SocialService>()
: null,
socialSettings: getIt<SocialSettings>(),
location: const GeolocatorCoarseLocation(),
outbox: getIt<OfferOutbox>(),