Skip to content

Commit

Permalink
refactor(eb-app-ui): sync lib/pri/identity.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
emrahcom committed Oct 14, 2024
1 parent 2d9f2f0 commit 2fff99d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions machines/eb-app-ui/home/ui/galaxy-dev/src/lib/pri/identity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { get } from "$lib/api";

// -----------------------------------------------------------------------------
export async function ping() {
try {
const now = new Date().getTime();
const pingedAt = globalThis.localStorage.getItem("pinged_at") || "0";

if (isNaN(Number(pingedAt))) {
globalThis.localStorage.setItem("pinged_at", String(now));
}

if (now - Number(pingedAt) > 60000) {
globalThis.localStorage.setItem("pinged_at", String(now));
await get("/api/pri/identity/ping");
}
} finally {
setTimeout(ping, 60000);
}
}

0 comments on commit 2fff99d

Please sign in to comment.