formatter

This commit is contained in:
Zacharias-Brohn
2026-02-25 17:29:14 +01:00
parent 15a112eaf7
commit 11da456048
2 changed files with 8 additions and 9 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
[General] [General]
FunctionsSpacing=true FunctionsSpacing=true
IndentWidth=4 IndentWidth=4
MaxColumnWidth=80 MaxColumnWidth=-1
NewlineType=native NewlineType=native
NormalizeOrder=true NormalizeOrder=true
ObjectsSpacing=true ObjectsSpacing=true
+7 -8
View File
@@ -16,6 +16,7 @@ import qs.Config
Singleton { Singleton {
id: root id: root
readonly property var appCooldownMap: new Map()
property alias dnd: props.dnd property alias dnd: props.dnd
property list<Notif> list: [] property list<Notif> list: []
property bool loaded property bool loaded
@@ -23,26 +24,24 @@ Singleton {
readonly property list<Notif> popups: list.filter(n => n.popup) readonly property list<Notif> popups: list.filter(n => n.popup)
property alias server: server property alias server: server
readonly property var appCooldownMap: new Map()
function shouldThrottle(appName: string): bool { function shouldThrottle(appName: string): bool {
if ( props.dnd ) if (props.dnd)
return false; return false;
const key = ( appName || "unknown" ).trim().toLowerCase(); const key = (appName || "unknown").trim().toLowerCase();
const cooldownSec = Config.notifs.appNotifCooldown; const cooldownSec = Config.notifs.appNotifCooldown;
const cooldownMs = Math.max(0, cooldownSec * 1000); const cooldownMs = Math.max(0, cooldownSec * 1000);
if ( cooldownMs <= 0 ) if (cooldownMs <= 0)
return true; return true;
const now = Date.now(); const now = Date.now();
const until = appCooldownMap.get( key ) ?? 0; const until = appCooldownMap.get(key) ?? 0;
if ( now < until ) if (now < until)
return false; return false;
appCooldownMap.set( key, now + cooldownMs ) appCooldownMap.set(key, now + cooldownMs);
return true; return true;
} }