zeeguu / web

Frontend for the zeeguu web application.
https://www.zeeguu.org
3 stars 5 forks source link

Initial language preferences fix #387

Closed igawaclawska closed 1 month ago

igawaclawska commented 1 month ago

Initial language preferences fix

The error:

After the user session handling update, the initial language preferences are saved to local storage on the /language_preferencespage. When the user goes to the /create_account page, the learned_language and native_language entries are erased from the local storage, which results in new accounts always set to German by default.

Possible cause:

The local storage entries (learned_language, learned_cefr_level, native_language) are already used in the system. They are associated with the /account_settings page and are likely linked to the user session data, which clashes with the initial language settings data before creating a user.

This clash can be easily observed in a slightly unnatural flow: If the existing user's practiced language is set to French, level 2 is on the /account_settings page, and if they go to the /language_preferences - no matter what they select in there - it will keep being overwritten and updated to French, level 2 on refresh. Something similar probably happens during account creation, but in that case, there is no user yet. Therefore, language selection entries are replaced/overwritten with no data.

The fix:

Separate temporary language preference entries for account creation have been created to prevent this clash. They are used only in the process of creating a new user .

    // language related keys used for initial language set-up during account creation
    LearnedLanguage_Initial: "learned_language_initial",
    NativeLanguage_Initial: "native_language_initial",
    LearnedCefrLevel_Initial: "learned_cefr_level_initial",

After a new user is created, the /account_settings page takes care of language preferences data.

netlify[bot] commented 1 month ago

Deploy Preview for voluble-nougat-015dd1 ready!

Name Link
Latest commit e531a462168d59071acb153791223c2695ed615c
Latest deploy log https://app.netlify.com/sites/voluble-nougat-015dd1/deploys/6651f10d6fa64c0008fa73d8
Deploy Preview https://deploy-preview-387--voluble-nougat-015dd1.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

mircealungu commented 1 month ago

I've merged and redeployed for now. You'll think more about the naming and if you want, send a new PR with it @igawaclawska