LearnNewsExamplesServices
Frontmatter
id8843
titlePersist Portal Theme Selection
stateClosed
labels
enhancementai
assigneestobiu
createdAtJan 21, 2026, 10:35 AM
updatedAtJan 21, 2026, 10:54 AM
githubUrlhttps://github.com/neomjs/neo/issues/8843
authortobiu
commentsCount1
parentIssue8727
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 21, 2026, 10:54 AM

Persist Portal Theme Selection

Closed v11.23.0 enhancementai
tobiu
tobiu commented on Jan 21, 2026, 10:35 AM

Enable persistence of the user's theme preference (Light/Dark) in the Portal App using LocalStorage.

Requirements:

  1. Save Preference: Update ViewportController.onSwitchTheme() to write the selected theme (e.g., neo-theme-neo-dark) to LocalStorage under the key portalTheme.
  2. Restore Preference: Implement logic on app startup (e.g., in onConstructed) to read the portalTheme from LocalStorage and apply it to the Viewport.
  3. Refactor: Ensure onSwitchTheme and the startup logic handle the asynchronous nature of LocalStorage interactions correctly.

Implementation Details:

  • Use Neo.main.addon.LocalStorage.
  • Context: apps/portal/view/ViewportController.mjs.
tobiu added the enhancement label on Jan 21, 2026, 10:35 AM
tobiu added the ai label on Jan 21, 2026, 10:35 AM
tobiu added parent issue #8727 on Jan 21, 2026, 10:35 AM
tobiu referenced in commit 7e3646a - "feat: Persist Portal Theme Selection (#8843)" on Jan 21, 2026, 10:53 AM
tobiu assigned to @tobiu on Jan 21, 2026, 10:53 AM
tobiu closed this issue on Jan 21, 2026, 10:54 AM
tobiu
tobiu Jan 21, 2026, 10:54 AM

Input from Gemini 3 Pro:

✦ I have implemented the theme persistence logic.

Changes:

  1. Refactored ViewportController: Introduced a centralized setTheme(theme, updateStorage) method to handle both UI updates (viewport theme, button icon) and optional LocalStorage persistence.
  2. App Startup: onConstructed now checks LocalStorage for the portalTheme key and applies it if found (without re-triggering a write).
  3. Theme Switching: onSwitchTheme now toggles the theme and calls setTheme with updateStorage=true, ensuring the user's preference is saved.

The code adheres to the DRY principle and correctly handles the asynchronous nature of LocalStorage reads during the construction phase.