diff --git a/server/util.lua b/server/util.lua index 04cf58924..e8fc3b81f 100644 --- a/server/util.lua +++ b/server/util.lua @@ -636,7 +636,9 @@ function util.cooldownLeft(cid, key, ms) if type(cid) ~= 'string' or cid == '' then return 0 end local b = buckets[cid .. '\0c\0' .. tostring(key)] if not b then return 0 end - local left = (tonumber(ms) or 0) - (GetGameTimer() - b.last) + local since = GetGameTimer() - b.last + if since < 0 then return 0 end + local left = (tonumber(ms) or 0) - since return left > 0 and math.floor(left) or 0 end diff --git a/web/src/apps/_games/useOnlineLobby.ts b/web/src/apps/_games/useOnlineLobby.ts index 31ba54554..ffee3cc14 100644 --- a/web/src/apps/_games/useOnlineLobby.ts +++ b/web/src/apps/_games/useOnlineLobby.ts @@ -128,8 +128,8 @@ export function useOnlineLobby(game: string, options: UseOnlineLobbyOptions): On const inHub = options.inLobbyScreen && !lobby && active; useEffect(() => { if (!inHub) return; - void lobbiesApi(game).then(setLobbies); - const timer = setInterval(() => { void lobbiesApi(game).then(setLobbies); }, 3000); + void lobbiesApi(game).then(setLobbies).catch(() => {}); + const timer = setInterval(() => { void lobbiesApi(game).then(setLobbies).catch(() => {}); }, 3000); return () => clearInterval(timer); }, [inHub, game]); @@ -228,7 +228,7 @@ export function useOnlineLobby(game: string, options: UseOnlineLobbyOptions): On setReadyApi(r); }, []); - const refresh = useCallback(() => { void lobbiesApi(game).then(setLobbies); }, [game]); + const refresh = useCallback(() => { void lobbiesApi(game).then(setLobbies).catch(() => {}); }, [game]); const returnToLobby = useCallback(() => { void returnToLobbyApi(game).then(r => { diff --git a/web/src/lib/clipboard.ts b/web/src/lib/clipboard.ts index 96a6b58f5..d2d753c27 100644 --- a/web/src/lib/clipboard.ts +++ b/web/src/lib/clipboard.ts @@ -24,7 +24,7 @@ export function copyToClipboard(text: string): boolean { ok = false; } - try { void navigator.clipboard?.writeText(text); } catch { /* ignore */ } + try { void navigator.clipboard?.writeText(text).catch(() => {}); } catch { /* ignore */ } return ok; }