-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save unconsumed state in DefaultStateKeeperDispatcher #179
Conversation
WalkthroughThe changes in the pull request focus on enhancing the Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/DefaultStateKeeperDispatcher.kt (1)
Missing test cases for router state preservation after configuration changes
The current test suite does not include test cases that verify the state preservation of
ChildStackRouter
within theRootStackRouter
hierarchy after multiple configuration changes, as described in issue #100. Consider adding these tests to ensure the issue is fully resolved.🔗 Analysis chain
Line range hint
1-62
: Verify the solution against the original issueThe changes made to
DefaultStateKeeperDispatcher
look promising in addressing the state loss issue after multiple configuration changes. However, it's important to verify if these changes fully solve the problem described in issue #100, particularly in the context of theRootStackRouter
andChildStackRouter
hierarchy.To ensure the changes effectively solve the issue, please run the following verification steps:
- Set up a test scenario mimicking the
RootStackRouter
andChildStackRouter
hierarchy described in issue Updated gradle-setup-plugin #100.- Implement multiple configuration changes (e.g., switching between Dark and Light themes).
- Verify that the
ChildStackRouter
maintains its stack after these configuration changes.If these tests don't exist, consider adding them to ensure the issue is fully resolved.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Search for relevant test cases that verify the state preservation in router hierarchies # Test: Look for test cases related to router state preservation rg -i "test.*router.*state.*configuration change" --type kotlin # Test: Check for any existing tests in DefaultStateKeeperDispatcherTest that might be relevant rg -A 10 "class DefaultStateKeeperDispatcherTest" --type kotlinLength of output: 1692
state-keeper/src/commonTest/kotlin/com/arkivanov/essenty/statekeeper/DefaultStateKeeperDispatcherTest.kt (2)
24-24
: Improved readability withserializeAndDeserialize()
The change simplifies the serialization and deserialization process, enhancing code readability. This is a good improvement that potentially reduces code duplication across tests.
Consider adding a brief comment explaining what
serializeAndDeserialize()
does, especially if it's defined in another file. This would improve code clarity for other developers.
37-59
: New test method effectively addresses the PR objectiveThis new test method is a valuable addition that directly addresses the issue of state loss after multiple configuration changes. It effectively simulates multiple recreations of the state keeper and verifies the correct restoration of both overwritten and unchanged data.
To further improve the test's readability and maintainability:
- Consider adding brief comments explaining the purpose of each dispatcher creation and state save/restore operation.
- You might want to add an assertion to verify that
key2
was not consumed indispatcher2
, to explicitly show that it remains unchanged throughout the process.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/DefaultStateKeeperDispatcher.kt (1 hunks)
- state-keeper/src/commonTest/kotlin/com/arkivanov/essenty/statekeeper/DefaultStateKeeperDispatcherTest.kt (2 hunks)
🧰 Additional context used
🔇 Additional comments (3)
state-keeper/src/commonMain/kotlin/com/arkivanov/essenty/statekeeper/DefaultStateKeeperDispatcher.kt (2)
Line range hint
9-9
: Improved state handling in the constructorThe initialization of
savedState
as a mutable map is a good improvement. It allows for more flexible state management and aligns with the PR objective of addressing state loss issues after multiple configuration changes.
15-16
: Enhanced state preservation in thesave
methodThe modification to initialize
map
fromsavedState
is an excellent improvement. It ensures that existing state is preserved when saving, effectively addressing the issue of state loss after multiple configuration changes. The use oftoMutableMap()
is a good practice to prevent unintended modifications to the originalsavedState
.state-keeper/src/commonTest/kotlin/com/arkivanov/essenty/statekeeper/DefaultStateKeeperDispatcherTest.kt (1)
60-60
: LGTM: Added blank line at end of fileAdding a blank line at the end of the file follows good coding practices and can help with certain version control systems.
Fixes xxfast/Decompose-Router#100.
Summary by CodeRabbit
New Features
Bug Fixes
Tests