diff --git a/assets/js/settings.js b/assets/js/settings.js index edda8e8..ea0775f 100644 --- a/assets/js/settings.js +++ b/assets/js/settings.js @@ -73,15 +73,22 @@ function applyPreferences() { // Save preferences async function saveSettings() { + const rowsPerPage = document.getElementById('rowsPerPage'); + const tableDensity = document.getElementById('tableDensity'); + const userTimezone = document.getElementById('userTimezone'); + const notificationsEnabled = document.getElementById('notificationsEnabled'); + const soundEffects = document.getElementById('soundEffects'); + const toastDuration = document.getElementById('toastDuration'); + const prefs = { - rows_per_page: document.getElementById('rowsPerPage').value, + rows_per_page: rowsPerPage ? rowsPerPage.value : '15', default_status_filters: Array.from(document.querySelectorAll('[name="defaultFilters"]:checked')) - .map(cb => cb.value).join(','), - table_density: document.getElementById('tableDensity').value, - timezone: document.getElementById('userTimezone').value, - notifications_enabled: document.getElementById('notificationsEnabled').checked ? '1' : '0', - sound_effects: document.getElementById('soundEffects').checked ? '1' : '0', - toast_duration: document.getElementById('toastDuration').value + .map(cb => cb.value).join(',') || 'Open,Pending,In Progress', + table_density: tableDensity ? tableDensity.value : 'normal', + timezone: userTimezone ? userTimezone.value : (window.APP_TIMEZONE || 'America/New_York'), + notifications_enabled: notificationsEnabled ? (notificationsEnabled.checked ? '1' : '0') : '1', + sound_effects: soundEffects ? (soundEffects.checked ? '1' : '0') : '1', + toast_duration: toastDuration ? toastDuration.value : '3000' }; try { @@ -154,7 +161,7 @@ document.addEventListener('keydown', (e) => { // ESC to close modal if (e.key === 'Escape') { const modal = document.getElementById('settingsModal'); - if (modal && modal.style.display === 'block') { + if (modal && modal.style.display !== 'none' && modal.style.display !== '') { closeSettingsModal(); } } diff --git a/models/UserModel.php b/models/UserModel.php index 04399c0..0b34865 100644 --- a/models/UserModel.php +++ b/models/UserModel.php @@ -302,7 +302,7 @@ class UserModel { sort($uniqueGroups); // Cache the result - self::setCache($cacheKey, $uniqueGroups); + self::setCached($cacheKey, $uniqueGroups); return $uniqueGroups; }