Skip to content

Keep the dark theme and shown tips across sign-in and sign-out - #77

Merged
dadachi merged 1 commit into
mainfrom
fix/keep-device-settings-on-sign-out
Oct 13, 2026
Merged

dadachi merged 1 commit into
mainfrom
fix/keep-device-settings-on-sign-out

Conversation

@dadachi

@dadachi dadachi commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

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() did toBuilder().clear(). It runs on every sign-in (SignInEmailAndPasswordViewModel clears 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's user_preferences.proto:

Field(s) Kept? Why
dark_theme_config kept A device/display setting chosen on this phone. Not account data.
did_show_tap_shop_below_tip kept A one-time "how to use the UI" tip. It holds no shopkeeper data, and the iOS app shows the same tip with TipKit, which is per device and survives sign-out.
id, account_id, personal_account_id, account_owner_id, account_name, email, name, time_zone, token, client, uid, expiry, is_logged_in cleared The session and the shopkeeper's identity.
permissions, android_app_version, should_update_app/privacy/terms, shop_limit_count cleared Come from GET /accounts/:id/permissions for 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.
locale cleared The shopkeeper's server-side language (AppLanguageSyncer compares against it). The app language itself is per-app/system, not stored here.
did_show_you_are_in_personal_account_alert cleared A per-session flag (unused in Free, kept in the proto).
is_email_updated, is_my_account_deleted, is_shop_deleted cleared One-shot snackbar triggers about the previous shopkeeper's actions. The two set around sign-out (is_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 old toBuilder().clear(). Replaces clearUserPreferences_resetsEverythingToTheDefaults, which pinned the bug as "current behavior".
  • NativeAppTemplatePreferencesDataSourceTest.clearSession_forgetsEverythingAboutTheShopkeeper: checks every per-account field against the proto3 defaults (stored locale ja before the clear, so the locale check is meaningful). Red when I made the clear also keep is_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).
  • The rest is the rename (clearSessionCallCount in TestLoginRepository, 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.nativeapptemplatefree debug build, local API)

System set to light mode so the app's Dark is visible.

  • Signed in as shopkeeper1, set Dark, signed out: the welcome and sign-in screens rendered dark.
  • Signed up and signed in as a throwaway shopkeeper: Shops rendered dark and Settings showed Dark. Dismissed the "Tap shop below" tip.
  • Changed the email in Edit Profile: the app signed out and the "confirmation link has been sent to your new email address" snackbar showed on the welcome screen.
  • Signed in again: still Dark, and the tip stayed dismissed.
  • Deleted the account: the "Account deleted successfully." snackbar showed on the welcome screen, and the server record is gone.
  • Signed in as shopkeeper1: Settings still showed Dark, no tip. Then set the theme back to System Default and the system back to dark mode.

🤖 Generated with Claude Code

https://claude.ai/code/session_01K5hZEFqXhBsUQwSWsgR6eH

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
@dadachi
dadachi merged commit 6bc058e into main Oct 13, 2026
1 check passed
@dadachi
dadachi deleted the fix/keep-device-settings-on-sign-out branch October 13, 2026 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant