1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-17 19:22:04 -04:00

notifications: add configurable durations for do not disturb

fixes #1481
This commit is contained in:
bbedward
2026-04-16 16:51:05 -04:00
parent c6e8067a22
commit 7ced91ede1
18 changed files with 868 additions and 40 deletions

View File

@@ -144,10 +144,48 @@ DankModal {
return "NOTIFICATION_MODAL_TOGGLE_DND_SUCCESS";
}
function enableDoNotDisturbFor(minutes: int): string {
if (minutes <= 0) {
return "ERROR: minutes must be > 0";
}
SessionData.setDoNotDisturb(true, minutes);
return "NOTIFICATION_MODAL_DND_SET_FOR_" + minutes + "_SUCCESS";
}
function enableDoNotDisturbUntil(timestampMs: string): string {
const ts = Number(timestampMs);
if (!ts || ts <= Date.now()) {
return "ERROR: timestamp must be a future epoch ms";
}
SessionData.setDoNotDisturbUntilTimestamp(ts);
return "NOTIFICATION_MODAL_DND_SET_UNTIL_SUCCESS";
}
function enableDoNotDisturbIndefinitely(): string {
SessionData.setDoNotDisturb(true, 0);
return "NOTIFICATION_MODAL_DND_INDEFINITE_SUCCESS";
}
function enableDoNotDisturbUntilTomorrowMorning(): string {
const now = new Date();
const target = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 8, 0, 0, 0);
SessionData.setDoNotDisturbUntilTimestamp(target.getTime());
return "NOTIFICATION_MODAL_DND_UNTIL_TOMORROW_SUCCESS";
}
function disableDoNotDisturb(): string {
SessionData.setDoNotDisturb(false);
return "NOTIFICATION_MODAL_DND_DISABLE_SUCCESS";
}
function getDoNotDisturb(): bool {
return SessionData.doNotDisturb;
}
function getDoNotDisturbUntil(): string {
return String(SessionData.doNotDisturbUntil);
}
function clearAll(): string {
notificationModal.clearAll();
return "NOTIFICATION_MODAL_CLEAR_ALL_SUCCESS";