diff --git a/frontend/src/components/Demo.tsx b/frontend/src/components/Demo.tsx index 99bc9ec..51adc2c 100644 --- a/frontend/src/components/Demo.tsx +++ b/frontend/src/components/Demo.tsx @@ -17,12 +17,6 @@ const Demo = ({ class: className }: DemoProps) => { const { id, downloads } = useSocket(); // TODO: Toasts - const randomBits = (bits: number) => - Math.floor(Math.random() * 2 ** bits) - .toString(16) - .padStart(bits / 4, "0") - .toUpperCase(); - const [highlightedIndex, setHighlightedIndex] = useState(null); const highlightedTimeoutRef = useRef(null); diff --git a/frontend/src/components/useSocket.ts b/frontend/src/components/useSocket.ts index b878c91..897b5cf 100644 --- a/frontend/src/components/useSocket.ts +++ b/frontend/src/components/useSocket.ts @@ -8,16 +8,14 @@ interface Download { } interface UseSocketResult { - sessionId: string | null; + id: string | null; downloads: Download[] | null; deleteDownload: (id: string) => void; } function useSocket(): UseSocketResult { - const [sessionId, setSessionId] = useState(null); - const [sessionDownloads, setSessionDownloads] = useState( - null - ); + const [id, setId] = useState(null); + const [downloads, setDownloads] = useState(null); function deleteDownload() {} @@ -39,8 +37,8 @@ function useSocket(): UseSocketResult { switch (data.type) { case "state": const downloads = data.downloads as Download[]; - setSessionId(data.session); - setSessionDownloads(downloads); + setId(data.session); + setDownloads(downloads); break; default: console.warn("Received unknown message type", data.type); @@ -57,7 +55,7 @@ function useSocket(): UseSocketResult { }; }, []); - return { sessionId, sessionDownloads, deleteDownload }; + return { id, downloads, deleteDownload }; } export default useSocket;