v0.2.18
RustBox CI / rustbox (push) Canceled after 0s

This commit is contained in:
Mateusz Gruszczyński committed 2026-11-03 12:11:13 +01:00
1 parent 1bb398acd1
commit 1309358b68
17 files changed
+239 -50

No files matched your search

+28
View File
@@ -263,6 +263,32 @@ function realtimeNotificationSuppressionKey(folder, accountId = state.accountId)
return `${accountId || ""}|${folder || "INBOX"}`;
}
function realtimeSuppressedMessageKey(folder, uid, accountId = state.accountId) {
return `${accountId || ""}|${folder || "INBOX"}|${Number(uid) || 0}`;
}
function suppressRealtimeNotificationForMessage(folder, uid, accountId = state.accountId, ttlMs = 15000) {
const numericUid = Number(uid);
if (!folder || !Number.isFinite(numericUid) || numericUid <= 0) return;
state.realtimeNotificationSuppressedMessages.set(
realtimeSuppressedMessageKey(folder, numericUid, accountId),
Date.now() + Math.max(3000, Number(ttlMs) || 15000),
);
}
function consumeRealtimeMessageNotificationSuppression(data, accountId) {
const now = Date.now();
for (const [key, expiresAt] of state.realtimeNotificationSuppressedMessages) {
if (Number(expiresAt) <= now) state.realtimeNotificationSuppressedMessages.delete(key);
}
const uid = Number(data?.latest_uid);
if (!Number.isFinite(uid) || uid <= 0) return false;
const key = realtimeSuppressedMessageKey(data?.folder, uid, accountId);
if (!state.realtimeNotificationSuppressedMessages.has(key)) return false;
state.realtimeNotificationSuppressedMessages.delete(key);
return true;
}
function suppressRealtimeNotificationsForFolder(folder, accountId = state.accountId) {
if (!folder) return () => { };
const key = realtimeNotificationSuppressionKey(folder, accountId);
@@ -294,6 +320,7 @@ function realtimeFolderIsDrafts(folderName) {
function realtimeNewMailNotificationsSuppressed(data, accountId) {
if (!state.realtimeNotificationsReady) return true;
if (realtimeFolderIsDrafts(data?.folder)) return true;
if (consumeRealtimeMessageNotificationSuppression(data, accountId)) return true;
return (state.realtimeNotificationSuppressions.get(realtimeNotificationSuppressionKey(data?.folder, accountId)) || 0) > 0;
}
@@ -317,6 +344,7 @@ function resetRealtimeNotificationGate() {
state.realtimeNotificationsReady = false;
state.realtimeNotificationsArmRequested = false;
state.realtimeNotificationSuppressions.clear();
state.realtimeNotificationSuppressedMessages.clear();
state.realtimeNotifiedMessages.clear();
}