Refactor KeepOnline logic and add useKeepOnline hook
Moved dashboard path check from KeepOnline to a new KeepOnlineWrapper component for cleaner separation of concerns. Introduced a reusable useKeepOnline hook to encapsulate the online status update logic. Updated layout to use KeepOnlineWrapper and simplified KeepOnline. Minor cleanup in broadcast-dialog.tsx.
This commit is contained in:
17
components/layout/KeepOnlineWrapper.tsx
Normal file
17
components/layout/KeepOnlineWrapper.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
"use client";
|
||||
|
||||
import { usePathname } from "next/navigation";
|
||||
import KeepOnline from "@/components/KeepOnline";
|
||||
|
||||
const KeepOnlineWrapper = () => {
|
||||
const pathname = usePathname();
|
||||
|
||||
// Only render KeepOnline on dashboard pages
|
||||
if (!pathname?.includes("/dashboard")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <KeepOnline />;
|
||||
};
|
||||
|
||||
export default KeepOnlineWrapper;
|
||||
Reference in New Issue
Block a user