feat : 6 astra improve it
CI / Verify and audit (push) Successful in 2m33s
CI / Build, scan and deploy immutable images (push) Failing after 1m29s

This commit is contained in:
2026-09-22 18:28:18 +07:00 Unverified
parent 88afa8e947
commit 87e6bcd96f
56 changed files with 1351 additions and 511 deletions
+6 -1
View File
@@ -1,6 +1,6 @@
"use client";
import { useEffect, useEffectEvent, useState } from "react";
import { useEffect, useEffectEvent, useRef, useState } from "react";
import { PRESENCE_HEARTBEAT_MS } from "@/lib/presence-constants";
@@ -49,7 +49,10 @@ function useHeartbeat<T>({
identifyBy: "browser" | "tab";
}) {
const [value, setValue] = useState<T | null>(null);
const pending = useRef(false);
const send = useEffectEvent(async (active = true) => {
if (active && (document.visibilityState !== "visible" || pending.current)) return;
pending.current = true;
try {
const response = await fetch(endpoint, {
method: "POST",
@@ -67,6 +70,8 @@ function useHeartbeat<T>({
if (active) setValue(await response.json() as T);
} catch {
if (active) setValue(null);
} finally {
pending.current = false;
}
});