diff --git a/.changeset/fix-sliding-sync-not-syncing-calls.md b/.changeset/fix-sliding-sync-not-syncing-calls.md new file mode 100644 index 000000000..890bf3519 --- /dev/null +++ b/.changeset/fix-sliding-sync-not-syncing-calls.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fix sliding sync not subscribing to call updates. diff --git a/src/app/features/room-nav/RoomNavItem.tsx b/src/app/features/room-nav/RoomNavItem.tsx index 12940f71e..306469dd0 100644 --- a/src/app/features/room-nav/RoomNavItem.tsx +++ b/src/app/features/room-nav/RoomNavItem.tsx @@ -354,9 +354,10 @@ export function RoomNavItem({ const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false); const { - onTouchStart, - onTouchEnd, - onTouchMove, + onPointerDown, + onPointerUp, + onPointerMove, + onPointerCancel, firedRef: longPressFiredRef, isPressing, } = useMobileLongPress(() => { @@ -457,9 +458,10 @@ export function RoomNavItem({ userSelect: 'none', WebkitUserSelect: 'none', }} - onTouchStart={onTouchStart} - onTouchEnd={onTouchEnd} - onTouchMove={onTouchMove} + onPointerDown={onPointerDown} + onPointerUp={onPointerUp} + onPointerMove={onPointerMove} + onPointerCancel={onPointerCancel} > { @@ -893,6 +894,7 @@ function MessageInternal( void, delay = 500) { const timerRef = useRef | null>(null); const firedRef = useRef(false); const [isPressing, setIsPressing] = useState(false); - const touchStartY = useRef(null); - const touchStartX = useRef(null); + const startY = useRef(null); + const startX = useRef(null); const clear = useCallback(() => { if (timerRef.current !== null) { @@ -14,19 +13,18 @@ export function useMobileLongPress(callback: () => void, delay = 500) { timerRef.current = null; } setIsPressing(false); - touchStartY.current = null; - touchStartX.current = null; + startY.current = null; + startX.current = null; }, []); - const onTouchStart = useCallback( - (e: React.TouchEvent | TouchEvent) => { - if (!mobileOrTablet()) return; + const onPointerDown = useCallback( + (e: React.PointerEvent | PointerEvent) => { + if (e.pointerType !== 'touch') return; firedRef.current = false; setIsPressing(true); - if (e.touches && e.touches[0]) { - touchStartY.current = e.touches[0].clientY; - touchStartX.current = e.touches[0].clientX; - } + startY.current = e.clientY; + startX.current = e.clientX; + timerRef.current = setTimeout(() => { firedRef.current = true; setIsPressing(false); @@ -36,20 +34,18 @@ export function useMobileLongPress(callback: () => void, delay = 500) { [callback, delay] ); - const onTouchEnd = useCallback(() => { + const onPointerUp = useCallback(() => { clear(); }, [clear]); - const onTouchMove = useCallback( - (e: React.TouchEvent | TouchEvent) => { - if (touchStartY.current === null || touchStartX.current === null || !e.touches || !e.touches[0]) { + const onPointerMove = useCallback( + (e: React.PointerEvent | PointerEvent) => { + if (startY.current === null || startX.current === null || e.pointerType !== 'touch') { clear(); return; } - const currentY = e.touches[0].clientY; - const currentX = e.touches[0].clientX; - const diffY = Math.abs(currentY - touchStartY.current); - const diffX = Math.abs(currentX - touchStartX.current); + const diffY = Math.abs(e.clientY - startY.current); + const diffX = Math.abs(e.clientX - startX.current); if (diffY > 10 || diffX > 10) { clear(); @@ -58,5 +54,7 @@ export function useMobileLongPress(callback: () => void, delay = 500) { [clear] ); - return { onTouchStart, onTouchEnd, onTouchMove, firedRef, isPressing }; + const onPointerCancel = useCallback(() => clear(), [clear]); + + return { onPointerDown, onPointerUp, onPointerMove, onPointerCancel, firedRef, isPressing }; }