From 30349ab14976c9a333d54701af6721dc59276679 Mon Sep 17 00:00:00 2001 From: emilielr Date: Fri, 15 Nov 2024 13:35:17 +0100 Subject: [PATCH] chore(): remove unused hooks --- tavla/src/Shared/hooks/useHash.ts | 24 ------------------- tavla/src/Shared/hooks/useToggle.ts | 13 ---------- tavla/src/Shared/hooks/useUpdateLastActive.ts | 20 ---------------- 3 files changed, 57 deletions(-) delete mode 100644 tavla/src/Shared/hooks/useHash.ts delete mode 100644 tavla/src/Shared/hooks/useToggle.ts delete mode 100644 tavla/src/Shared/hooks/useUpdateLastActive.ts diff --git a/tavla/src/Shared/hooks/useHash.ts b/tavla/src/Shared/hooks/useHash.ts deleted file mode 100644 index 924c4b818..000000000 --- a/tavla/src/Shared/hooks/useHash.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { useRouter } from 'next/router' - -function useHashState(id: string) { - const router = useRouter() - const hash = router.asPath.split('#')[1] ?? '' - const isOpen = hash === id - const open = () => { - router.push({ - query: { ...router.query }, - pathname: router.pathname, - hash: id, - }) - } - const close = () => { - router.push({ - query: { ...router.query }, - pathname: router.pathname, - hash: '', - }) - } - return { isOpen, open, close } -} - -export { useHashState } diff --git a/tavla/src/Shared/hooks/useToggle.ts b/tavla/src/Shared/hooks/useToggle.ts deleted file mode 100644 index dc6e9edbb..000000000 --- a/tavla/src/Shared/hooks/useToggle.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { useState } from 'react' - -function useToggle() { - const [isEnabled, setIsEnabled] = useState(false) - - const enable = () => setIsEnabled(true) - - const disable = () => setIsEnabled(false) - - return [isEnabled, enable, disable] as const -} - -export { useToggle } diff --git a/tavla/src/Shared/hooks/useUpdateLastActive.ts b/tavla/src/Shared/hooks/useUpdateLastActive.ts deleted file mode 100644 index 4a1ab71b1..000000000 --- a/tavla/src/Shared/hooks/useUpdateLastActive.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { useCallback, useEffect } from 'react' -import { TBoardID } from 'types/settings' - -function useUpdateLastActive(documentId: TBoardID | undefined) { - const updateLastActive = useCallback(async () => { - await fetch(`/api/ping/${documentId}`, { - method: 'POST', - }) - }, [documentId]) - - useEffect(() => { - updateLastActive() - const intervalId = setInterval(updateLastActive, 1000 * 60 * 60 * 24) - return () => { - clearInterval(intervalId) - } - }, [updateLastActive]) -} - -export { useUpdateLastActive }