Fix local settings page for anonymous users

This commit is contained in:
Liam 2025-01-24 20:05:36 -05:00
parent f1a5f7739d
commit 3c7c1e1ec1

View file

@ -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 = $<HTMLSelectElement>('#user_theme_name');
if (!themeSelect) return;
const localCheckboxes = $$<HTMLInputElement>('[data-tab="local"] input[type="checkbox"]');
const themeSelect = assertNotNull($<HTMLSelectElement>('#user_theme_name'));
const themeColorSelect = assertNotNull($<HTMLSelectElement>('#user_theme_color'));
const themePaths: Record<string, string> = JSON.parse(
assertNotUndefined(assertNotNull($<HTMLDivElement>('#js-theme-paths')).dataset.themePaths),
);
const styleSheet = assertNotNull($<HTMLLinkElement>('#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 = $$<HTMLInputElement>('[data-tab="local"] input[type="checkbox"]');
// Local settings
localCheckboxes.forEach(checkbox => {
checkbox.addEventListener('change', () => {
store.set(checkbox.id.replace('user_', ''), checkbox.checked);
});
});
setupThemeSettings();
}