24 lines
582 B
TypeScript
24 lines
582 B
TypeScript
"use client";
|
|
|
|
import { useEffect } from "react";
|
|
import { clientFetch } from "@/lib/api";
|
|
|
|
const KeepOnline = () => {
|
|
useEffect(() => {
|
|
if(window.location.pathname.includes("/dashboard")){
|
|
const updateOnlineStatus = () => {
|
|
console.log("Updating online status...");
|
|
clientFetch('/auth/me');
|
|
}
|
|
|
|
// Start interval without immediate call
|
|
const interval = setInterval(updateOnlineStatus, 1000*60*1);
|
|
|
|
return () => clearInterval(interval);
|
|
}
|
|
}, []);
|
|
|
|
return null;
|
|
}
|
|
|
|
export default KeepOnline; |