Repository navigation
Show stored snackbar notices once, not again after a relaunch - #81
Merged
Merged
Conversation
The app root showed the notices stored in DataStore (shop deleted, email changed, account deleted) in a LaunchedEffect keyed on the flag, and cleared the flag only after the Indefinite snackbar was dismissed. Closing the app while the snackbar was up left the flag set, so "Shop removed." came back at every launch. The flag is now cleared as soon as the notice is taken for display, in a collected effect so clearing it does not cancel the snackbar. The shop-deleted notice, stored just before the app restarts itself, is read once at launch: the process that stored it would otherwise take the flag and lose the snackbar a moment later when it exits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K5hZEFqXhBsUQwSWsgR6eH
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.
Bug
After a shop is deleted (which restarts the app), closing or force-stopping the app while the "Shop removed." snackbar is still up made it show again at every launch.
NativeAppTemplateAppshowed each notice stored in DataStore (isShopDeleted,isEmailUpdated,isMyAccountDeleted) in aLaunchedEffectkeyed on the flag. It cleared the flag only after the Indefinite snackbar returned, i.e. after the shopkeeper dismissed it. The paid app has the same bug, found with "Switched organization": nativeapptemplate/NativeAppTemplate-Android#115.Fix
New
ui/app_root/StoredNotice.kt:appState) instead of being keyed on it, so clearing it does not cancel the snackbar.showStoredNotice(collects while the app runs) is used for the sign-out notices (isEmailUpdated,isMyAccountDeleted), which the same process shows.showNoticeStoredForLaunch(reads the flag once at launch) is used forisShopDeleted, which is stored just beforerestartApp(). With live collection, the process that stored the flag would take it, clear it and start the snackbar right before it exits, so the restarted app would not show it. This was seen on device in the paid app.isEmailUpdated/isMyAccountDeleted/isShopDeletedstate flows are removed fromNativeAppTemplateAppState, along with their test (deletionFlags_comeFromThePreferences). The effects read the DataStore flows directly, becausefirst()on astateInflow would return its initialfalse.Tests
StoredNoticeTestsimulates app processes against oneInMemoryDataStore, which plays the role of the DataStore file that outlives the process. Cancelling a launch means the process ended with the snackbar still up.shopDeleted_isShownOnceByTheRestartedApp_evenIfItIsClosedWhileTheNoticeShowsemailUpdated_isShownOnceByTheRunningApp_evenIfItIsClosedWhileTheNoticeShowsemailUpdated_storedAgain_isShownAgainSeen red:
showNoticeStoredForLaunchwith show-then-clear (the original order):expected:<1> but was:<2>. With live collection:expected:<0> but was:<1>.showStoredNoticewith show-then-clear:expected:<1> but was:<2>.Local checks
./scripts/pre-pushpasses: spotlessCheck, lintDebug,:app:minifyReleaseWithR8and test. 409 test cases, 0 failures.Device check (Pixel, local API, shopkeeper1)
🤖 Generated with Claude Code
https://claude.ai/code/session_01K5hZEFqXhBsUQwSWsgR6eH