Repository navigation
Keep the dark theme and shown tips across sign-in and sign-out - #77
Merged
Merged
Conversation
clearUserPreferences() did toBuilder().clear(), and it runs on every sign-in (before storing the new session), sign-out and account deletion, so the dark-theme choice and the "tap shop below" tip were reset each time. Renamed to clearSession(): it resets the proto to its defaults except dark_theme_config and did_show_tap_shop_below_tip, which are device settings rather than the shopkeeper's data. 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.
Phase 2 follow-up (bug fixes). Port of NativeAppTemplate-Android #109, bug 1. (Bug 2 of that PR, the skipped push cleanup on account deletion, does not apply: the Free edition has no push notifications.)
Sign-in, sign-out and account deletion reset the device settings
clearUserPreferences()didtoBuilder().clear(). It runs on every sign-in (SignInEmailAndPasswordViewModelclears before storing the new session), every sign-out (LoginRepositoryImpl.logout, on success and on failure) and on account deletion (ShopkeeperEditViewModel.deleteShopkeeper). So each of these reset the dark-theme choice to "System Default" and showed the "Tap shop below" tip again.Fix: renamed to
clearSession(). It resets the proto to its defaults except the two device settings. Decision per field of Free'suser_preferences.proto:dark_theme_configdid_show_tap_shop_below_tipid,account_id,personal_account_id,account_owner_id,account_name,email,name,time_zone,token,client,uid,expiry,is_logged_inpermissions,android_app_version,should_update_app/privacy/terms,shop_limit_countGET /accounts/:id/permissionsfor the signed-in account and are fetched again after sign-in. Keeping them would show the previous shopkeeper's limit or update prompts until that fetch finishes.localeAppLanguageSyncercompares against it). The app language itself is per-app/system, not stored here.did_show_you_are_in_personal_account_alertis_email_updated,is_my_account_deleted,is_shop_deletedis_email_updated,is_my_account_deleted) are set after the clear, as before, so their snackbars still work (checked on the device, below).Free has no
device_id, organization or invitation fields, so those rows of the paid table do not apply.Tests (each seen red before the fix)
NativeAppTemplatePreferencesDataSourceTest.clearSession_keepsTheDeviceSettings: red with the oldtoBuilder().clear(). ReplacesclearUserPreferences_resetsEverythingToTheDefaults, which pinned the bug as "current behavior".NativeAppTemplatePreferencesDataSourceTest.clearSession_forgetsEverythingAboutTheShopkeeper: checks every per-account field against the proto3 defaults (stored localejabefore the clear, so the locale check is meaningful). Red when I made the clear also keepis_shop_deleted.LoginRepositoryImplTest.logout_keepsTheDarkTheme: red with the old clear.NativeAppTemplatePreferencesDataSourceWriteFailureTest: the log message is now "Failed to clear the session" (red until the message changed).clearSessionCallCountinTestLoginRepository, etc.).Local checks
./scripts/pre-push(spotless, lint, R8 shrink, unit tests): passed. 400 unit tests, 0 failures../gradlew :app:assembleRelease: passed.Device check (Pixel,
com.nativeapptemplate.nativeapptemplatefreedebug build, local API)System set to light mode so the app's Dark is visible.
🤖 Generated with Claude Code
https://claude.ai/code/session_01K5hZEFqXhBsUQwSWsgR6eH