From de3401b0f33414e2f0868e3d096c9dcd6848a8ee Mon Sep 17 00:00:00 2001 From: Georgi Davidkov Date: Fri, 10 May 2024 17:31:00 +0300 Subject: [PATCH] G4E-7902 - fix settings --- js/connect-related.js | 19 +------------------ js/settings.js | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/js/connect-related.js b/js/connect-related.js index dc8ee58..ef6e494 100644 --- a/js/connect-related.js +++ b/js/connect-related.js @@ -346,7 +346,6 @@ async function getNotificationsConfiguration() { }; setSetting(setting); - updatePrefs(setting); } } @@ -369,22 +368,6 @@ async function trackNotificationsConfigurationChange() { }; setSetting(setting); - updatePrefs(setting); - - const notificationPanel = q('#notification-panel'); - const enableNotificationsCheckbox = q('#enable-notifications'); - const enableToastsCheckbox = q('#enable-toasts'); - - if (enable) { - notificationPanel.classList.remove('d-none'); - enableNotificationsCheckbox.checked = true; - enableToastsCheckbox.disabled = false; - } else { - notificationPanel.classList.add('d-none'); - enableNotificationsCheckbox.checked = false; - enableToastsCheckbox.checked = false; - enableToastsCheckbox.disabled = true; - } }); } } @@ -396,7 +379,7 @@ async function openNotificationPanel() { if (isPanelVisible) { await glue.notifications.panel.hide(); } else { - await glue.notifications.panel.show(); + await glue.notifications.panel.show(); } } diff --git a/js/settings.js b/js/settings.js index 0a54209..ea1d91e 100644 --- a/js/settings.js +++ b/js/settings.js @@ -34,6 +34,23 @@ async function populateSettings() { ) { let checkbox = q(`#settings-content [setting='${setting}']`); + const notificationPanel = q('#notification-panel'); + const enableNotificationsCheckbox = q('#enable-notifications'); + const enableToastsCheckbox = q('#enable-toasts'); + if (setting === "enableNotifications") { + const enable = settings[setting]; + if (enable) { + notificationPanel.classList.remove('d-none'); + enableNotificationsCheckbox.checked = true; + enableToastsCheckbox.disabled = false; + } else { + notificationPanel.classList.add('d-none'); + enableNotificationsCheckbox.checked = false; + enableToastsCheckbox.checked = false; + enableToastsCheckbox.disabled = true; + } + } + getSetting(setting) ? checkbox.setAttribute('checked', true) : checkbox.removeAttribute('checked'); @@ -48,17 +65,17 @@ function trackSettingsChange() { .find((e) => e && e.getAttribute && e.getAttribute('setting')); if (settingElement) { - const setting = {}; + let setting = {}; setting[settingElement.getAttribute('setting')] = e.srcElement.checked; - setSetting(setting); if ( e.target.getAttribute('setting') === 'enableNotifications' && e.srcElement.checked === false ) { - setSetting({ enableNotifications: false, enableToasts: false }); + setting = { enableNotifications: false, enableToasts: false }; } + setSetting(setting); } }); } @@ -84,6 +101,7 @@ function setSetting(setting) { } updatePrefs(setting); + populateSettings(); } export {