notifications: Ensure correct state is being set for do not disturb

Change the "toggleDoNotDisturbMode" function to "setDoNotDisturbMode"
and add a parameter so that we actually set the mode to the intended
value, not just flip it.
This commit is contained in:
Devin Lin 2025-08-07 12:10:37 -04:00
parent 3d068528d0
commit 54cd4d548e

View file

@ -129,12 +129,21 @@ Item {
} }
/** /**
* Toggles Do Not Disturb mode. * Sets Do Not Disturb mode to the intended setting.
* Note: The state may not change to the desired setting, always read doNotDisturbEnabled for the current state.
*/ */
function toggleDoNotDisturbMode() { function setDoNotDisturbMode(doNotDisturb: bool) {
if (doNotDisturbModeEnabled) { if (!doNotDisturb) {
notificationSettings.defaults(); // Turn off do not disturb
notificationSettings.notificationsInhibitedUntil = undefined;
notificationSettings.revokeApplicationInhibitions();
notificationSettings.fullscreenFocused = false;
// overrules current mirrored screen setup, updates again when screen configuration changes
notificationSettings.screensMirrored = false;
} else { } else {
// Turn on do not disturb
// We just have a global toggle, so set it to a really long time (in this case, a year) // We just have a global toggle, so set it to a really long time (in this case, a year)
var until = new Date(); var until = new Date();
until.setFullYear(until.getFullYear() + 1); until.setFullYear(until.getFullYear() + 1);
@ -157,7 +166,7 @@ Item {
function onDoNotDisturbChanged() { function onDoNotDisturbChanged() {
if (root.doNotDisturbModeEnabled !== MobileShellState.ShellDBusClient.doNotDisturb) { if (root.doNotDisturbModeEnabled !== MobileShellState.ShellDBusClient.doNotDisturb) {
root.toggleDoNotDisturbMode(); root.setDoNotDisturbMode(MobileShellState.ShellDBusClient.doNotDisturb);
} }
} }
} }