mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-22 21:28:12 +02:00
feat: refactor long-press functionality in AllPrivateChatsSidebar and AllSharedChatsSidebar to utilize custom hook for improved code reusability and maintainability
This commit is contained in:
parent
2ea67c1764
commit
37e1995546
3 changed files with 41 additions and 49 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { useCallback, useRef } from "react";
|
||||
import { useCallback, useEffect, useRef } from "react";
|
||||
|
||||
const LONG_PRESS_DELAY = 500;
|
||||
|
||||
|
|
@ -21,6 +21,14 @@ export function useLongPress(onLongPress: () => void, delay = LONG_PRESS_DELAY)
|
|||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (timerRef.current) {
|
||||
clearTimeout(timerRef.current);
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
const handlers = {
|
||||
onTouchStart: start,
|
||||
onTouchEnd: cancel,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue