fix(android): ExclusionsViewModel in factory — 0.10.7 launch crash #1374
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/exclusions-viewmodel-factory"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Root cause (verified on the user's device)
Release 0.10.7 crashes on every launch:
MemoriesAppcreates the shared exclusion ledger (exclusionLedger: ExclusionsViewModel = viewModel(factory = viewModelFactory), app-scope, line 217) eagerly at startup, butAppViewModelFactoryhad no branch forExclusionsViewModel— thewhenfell through toelse -> throw. The feature PR (#1372) shipped the ViewModel and screen but never registered the factory branch; the per-VM unit tests construct the ViewModel directly and structurally cannot catch a missing branch.Fix
Register the branch in
AppViewModelFactory(pattern-identical toTrashViewModel):excludedMedia = container.excludedMedia,mediaStates = container.mediaStates(both already onAppContainer)excludedAlbumsSource = PreferenceExcludedAlbumsSource(container.albumPreferences)— the same album-preference store the album screens readapi/sessionProvider/onUnauthorizedwired like every other authenticated branchintentRecorder= the same spec-044-S3 record-on-failure retry queue the trash/timeline branches use ("Auch aus Memories entfernen" reuses the trash endpoint)resolverkeeps the ViewModel default for now — the productionScanResolvingExclusionsneeds aMediaStoreScanner, which the container does not expose (follow-up wiring, noted in a code comment; excludes still work — only the pre-exclude "already in Memories?" analysis degrades until then)Minimal testability seam: the factory now takes a narrow
AppViewModelFactory.Depsinterface (one member perAppContainerproperty it reads) with aContainerDepsadapter; the existingAppViewModelFactory(container)constructor is kept, soMainActivityand all call sites are unchanged.AppContaineritself cannot be built in a JVM test (eagerEncryptedSharedPreferences/AndroidKeyStore + WorkManager).Regression canary test (
AppViewModelFactoryTest, Robolectric because one branch readsBuild.MANUFACTURER):creates ExclusionsViewModel — the 0_10_7 launch crash regression— the exact call that crashed every launchcreates every other ViewModel the app requests from the factory— all 17 remaining branches, asserting the created instance is of the requested class (catches missing branches and dispatch-order mistakes)an unregistered ViewModel class still fails loudly— theelseguard staysKNOWN_ISSUES.md: ISSUE-202 (high/resolved/area:android).Validation
./gradlew :app:testDebugUnitTest— 691 tests, 0 failures, 0 errors, 0 skipped (new canary: 3/3).