From 3c7c1e1ec10576d8116c7c42f3374926114c93c8 Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 24 Jan 2025 20:05:36 -0500 Subject: [PATCH] Fix local settings page for anonymous users --- assets/js/settings.ts | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/assets/js/settings.ts b/assets/js/settings.ts index f40fa439..a272b5e4 100644 --- a/assets/js/settings.ts +++ b/assets/js/settings.ts @@ -6,24 +6,16 @@ import { assertNotNull, assertNotUndefined } from './utils/assert'; import { $, $$ } from './utils/dom'; import store from './utils/store'; -export function setupSettings() { - if (!$('#js-setting-table')) return; +function setupThemeSettings() { + const themeSelect = $('#user_theme_name'); + if (!themeSelect) return; - const localCheckboxes = $$('[data-tab="local"] input[type="checkbox"]'); - const themeSelect = assertNotNull($('#user_theme_name')); const themeColorSelect = assertNotNull($('#user_theme_color')); const themePaths: Record = JSON.parse( assertNotUndefined(assertNotNull($('#js-theme-paths')).dataset.themePaths), ); const styleSheet = assertNotNull($('#js-theme-stylesheet')); - // Local settings - localCheckboxes.forEach(checkbox => { - checkbox.addEventListener('change', () => { - store.set(checkbox.id.replace('user_', ''), checkbox.checked); - }); - }); - // Theme preview const themePreviewCallback = () => { const themeName = assertNotUndefined(themeSelect.options[themeSelect.selectedIndex].value); @@ -35,3 +27,18 @@ export function setupSettings() { themeSelect.addEventListener('change', themePreviewCallback); themeColorSelect.addEventListener('change', themePreviewCallback); } + +export function setupSettings() { + if (!$('#js-setting-table')) return; + + const localCheckboxes = $$('[data-tab="local"] input[type="checkbox"]'); + + // Local settings + localCheckboxes.forEach(checkbox => { + checkbox.addEventListener('change', () => { + store.set(checkbox.id.replace('user_', ''), checkbox.checked); + }); + }); + + setupThemeSettings(); +}