Skip to content

fix: boot in the account's language when offline - #2146

Open
Cartoone9 wants to merge 1 commit into
liketrek:devfrom
Cartoone9:fix/offline-language-mirror
Open

fix: boot in the account's language when offline#2146
Cartoone9 wants to merge 1 commit into
liketrek:devfrom
Cartoone9:fix/offline-language-mirror

Conversation

@Cartoone9

Copy link
Copy Markdown
Contributor

Small fix for something I hit using the PWA offline: a cold start with no network boots in English even though my account language is set. Offered in case the approach fits, happy to adjust if you'd prefer a different shape. Based on dev.

What happens

The store boots from app_language in localStorage, which is only written when a language is explicitly picked in Settings. A language that lives in the account's server settings never reaches the device, so an offline launch falls back to en until a fetch that cannot happen. It looks like the same stranding #1618 addressed for currency and units, with the language left out.

The change

loadSettings mirrors the fetched language into its own key (app_language_server), and the boot chain reads: explicit choice, then mirror, then en.

I kept it a separate key on purpose: app_language currently means "the user chose this", and hasStoredLanguage() gates the login page's browser-language detection on it. Mirroring into the same key would have silently disabled that detection after any successful settings load. If you'd rather fold them together anyway, or mirror somewhere else entirely, happy to rework it.

Tests

  • SETTINGS-LANG-001: loadSettings mirrors the account language for the next launch
  • SETTINGS-LANG-002: the mirror never claims to be an explicit choice
  • SETTINGS-LANG-003: a cold start with no explicit choice boots in the mirrored language
  • SETTINGS-LANG-004: an explicit in-app choice outranks the mirror

Full client suite passes.

The store boots from localStorage, but 'app_language' is only written
on an explicit in-app choice; a language that lives in the account's
server settings never reaches the device. A PWA cold start with no
network then runs in English even though every online session ran in
the user's language, the same stranding liketrek#1618 fixed for currency and
units.

loadSettings now mirrors the fetched language into its own key
('app_language_server'), and the boot chain falls back to it between
the explicit choice and 'en'. A separate key on purpose: 'app_language'
means an explicit choice, and the login page's detection chain must
keep running for users who never made one.
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