added Sounds für Livekit

This commit is contained in:
PxlLoewe
2025-06-02 16:28:44 -07:00
parent 78fa0542e2
commit bb931ee9d3
13 changed files with 137 additions and 6 deletions

View File

@@ -0,0 +1,30 @@
import { useCallback, useEffect, useRef } from "react";
export default function useTimeout(callback: () => void, delay: number) {
const callbackRef = useRef(callback);
const timeoutRef = useRef<NodeJS.Timeout>(null);
useEffect(() => {
callbackRef.current = callback;
}, [callback]);
const set = useCallback(() => {
timeoutRef.current = setTimeout(() => callbackRef.current(), delay);
}, [delay]);
const clear = useCallback(() => {
if (timeoutRef.current) clearTimeout(timeoutRef.current);
}, []);
useEffect(() => {
set();
return clear;
}, [delay, set, clear]);
const reset = useCallback(() => {
clear();
set();
}, [clear, set]);
return { reset, clear, set };
}