Skip to content

UI: configure settings via URL params#31244

Merged
andig merged 1 commit into
masterfrom
ui-settings-via-url
Jun 26, 2026
Merged

UI: configure settings via URL params#31244
andig merged 1 commit into
masterfrom
ui-settings-via-url

Conversation

@naltatis

@naltatis naltatis commented Jun 26, 2026

Copy link
Copy Markdown
Member

Addresses #6922

Lets kiosk displays and iframe embeds force UI preferences through the URL instead of relying on browser settings or persisted storage. Params are validated, written to the existing localStorage-backed settings, then stripped from the address bar.

  • ?theme=, ?lang=, ?unit=, ?format= applied on boot (e.g. ?theme=dark&lang=de&unit=mi&format=24)
  • values persist to localStorage, so a cleared kiosk reapplies them on reload

Todo

Apply theme, language, unit and time format from URL query params on
boot, persist to localStorage, then strip them from the address bar.
For kiosk displays and iframe embeds.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • In app.ts, applyUrlSettings() is called but the function is not imported; add an explicit import from ./urlSettings to avoid runtime/compile errors.
  • In urlSettings.ts, consider using the existing setters (e.g. setThemePreference, unit/time-format helpers, locale setter) instead of mutating the settings object directly so that any associated side effects (localStorage writes, DOM updates, reactive state) stay consistent with the rest of the app.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `app.ts`, `applyUrlSettings()` is called but the function is not imported; add an explicit import from `./urlSettings` to avoid runtime/compile errors.
- In `urlSettings.ts`, consider using the existing setters (e.g. `setThemePreference`, unit/time-format helpers, locale setter) instead of mutating the `settings` object directly so that any associated side effects (localStorage writes, DOM updates, reactive state) stay consistent with the rest of the app.

## Individual Comments

### Comment 1
<location path="assets/js/urlSettings.ts" line_range="20" />
<code_context>
+  if (lang === "auto") {
+    settings.locale = null;
+    touched = true;
+  } else if (lang && lang in LOCALES) {
+    settings.locale = lang as keyof typeof LOCALES;
+    touched = true;
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Use a safer own-property check instead of `in` for LOCALES lookup.

`lang in LOCALES` will also match properties on LOCALES’ prototype chain. To ensure only real locale keys are treated as valid, use an own-property check instead, e.g. `Object.prototype.hasOwnProperty.call(LOCALES, lang)` or `Object.hasOwn(LOCALES, lang)` where available.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread assets/js/urlSettings.ts
@naltatis naltatis added enhancement New feature or request ux User experience/ interface labels Jun 26, 2026
@andig andig merged commit b0a3564 into master Jun 26, 2026
30 checks passed
@andig andig deleted the ui-settings-via-url branch June 26, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ux User experience/ interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants