Settings menu #47
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When entering the settings from the main menu it shows a "Syntax Error" and the settings menu does not display and when closing it also does not display again the main menu. Can you fix that?
I'll investigate the settings window and the main menu flow.
Let me test a hypothesis about
useI18n+GetUserSettingbehavior directly in Node.Now I have the diagnosis. Let me verify it precisely before fixing:
Confirmed the root cause. Now the fix:
Now the test, following the repo's existing vm/source-reading style:
Fixed, diagnosed, and covered by tests.
Root cause
SettingsWindow.vuewrote the value it read from the server straight into vue‑i18n's global locale:For every account that never picked a language there is nothing stored:
GET /user/get-settingsanswersres.json({status:'ok', settings: data.settings})→settings: undefined, soGetUserSetting('lang')returnsundefined. vue‑i18n rejects a locale of that type on the next translation — I reproduced it against the version the lockfile pins (vue‑i18n 11.4.14):That is the "Syntax Error" in the issue. Because the locale is global and reactive, every translation in every window throws from then on: the settings window never renders, and the main menu behind it goes down with it (the error page replaces the app), which is why closing settings did not bring the main menu back either.
Changes
frontend/app/components/windows/SettingsWindow.vueapplyLanguage(code)puts a language into vue‑i18n only when it is one of the codes ini18n/locales.ts; no stored language (or one no longer offered) leaves the language on screen alone, and a failed settings request is caught instead of poisoning the locale.localeToShow(code)seeds the dropdown with the language actually being shown instead of an empty row, andgetLocaleNameno longer dereferences a locale that is not there.changeLocaleonly saves a language it managed to apply (and no longer logs the option object).GetUser()?.admin— an expired token made the sameonBeforeMounthook throw while opening the settings.frontend/app/services/WindowDefinitions.jsCreateWindowleaves the already‑open main menu alone, so it never doubles).tests/settings-window.test.js(new, 10 tests) — the window script is lifted out of its<script setup>into anode:vmcontext withlocale/selectedLocaleas plain refs, the waytests/sidebar-section-pane.test.jsdoes it: nothing but a looked‑up locale reaches vue‑i18n, an unknown/missing stored language leaves it untouched, a known one is applied and shown, the dropdown always has a row, and closing the window restores the main menu.Verification
node --test tests/→ 131 tests, 131 pass, 0 fail (121 pre‑existing + 10 new).pnpm --filter ./frontend run build→ build complete; both changed modules also transform cleanly throughnuxt dev.Nothing committed or pushed.
One pre-existing gap I did not touch (separate, unimplemented feature): the admin‑only "Manage accounts" button in the same window calls
CreateWindow('account_management', …), butaccount_managementis not registered inWindowDefinitions.js, so clicking it crashes the window app the same way — and theClearWindow('settings')calls in that handler pass a string where a{type}/{id}selector is expected. Worth its own issue.Implementation is ready for review: #50