Repository navigation
Give each screen its own view models so the profile editor loads - #75
Merged
Merged
Conversation
Navigation had no view model store per back stack entry, so view models were shared through the activity: a second profile (or widget) editor reused the first one's view model and the id it was opened with. After a new profile had been discarded, every profile editor kept waiting for that missing profile. Entries now get their own view models (lifecycle-viewmodel-navigation3), cleared when they leave the back stack. An untouched new profile is discarded then, not when the editor is merely hidden by a tab switch, and an editor whose profile no longer exists goes back instead of loading forever. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The profile editor could get stuck on its loading spinner forever (seen on a device with the 3.0 builds, beta 3.0.0-200 included).
Cause:
NavigationState.toEntriesonly used the saveable-state decorator, so view models were scoped to the activity and shared by key. A second profile editor reused the first one'sWidgetProfileEditorViewModeland the profile id it was created with; the widget editor had the same flaw. Once a new profile had been discarded, every later profile editor kept observing that missing profile.Fix:
rememberViewModelStoreNavEntryDecorator(lifecycle-viewmodel-navigation32.11.0): each back stack entry gets its own view models, cleared when it is poppedonCleared(editor really closed), no longer on composition dispose, which also fired on a tab switch and deleted the profile under the open editorTests: navigation view model scoping (separate per entry, survives a tab switch), new-profile discard on close but not on hide, missing profile. Verified on an emulator: a new profile survives a tab switch, is discarded on back, and opening another profile afterwards loads.
🤖 Generated with Claude Code