Skip to content

Commit

Permalink
Merge pull request #44 from InteropIO/G4E-7902-The-Enable-Notificatio…
Browse files Browse the repository at this point in the history
…n-checkbox-in-settings-stays-checked-although-the-notifications-are-disabled-on-the-system-level

G4E-7902 - fix settings
  • Loading branch information
galin-iliev authored Jun 11, 2024
2 parents 2d964ab + 9d50f96 commit 0cf6044
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
17 changes: 0 additions & 17 deletions js/connect-related.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ async function getNotificationsConfiguration() {
};

setSetting(setting);
updatePrefs(setting);
}
}

Expand All @@ -395,22 +394,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;
}
});
}
}
Expand Down
24 changes: 21 additions & 3 deletions js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,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');
Expand All @@ -49,17 +66,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);
}
});
}
Expand All @@ -85,6 +102,7 @@ function setSetting(setting) {
}

updatePrefs(setting);
populateSettings();
}

export {
Expand Down

0 comments on commit 0cf6044

Please sign in to comment.