openJoinAlias,
openProfileViewer,
selectRoom,
- selectSpace,
+ selectTab,
} from '../../../client/action/navigation';
import { useForceUpdate } from '../../hooks/useForceUpdate';
import { parseGeoUri, scaleYDimension } from '../../utils/common';
import * as customHtmlCss from '../../styles/CustomHtml.css';
import { RoomIntro } from '../../components/room-intro';
import {
- OnIntersectionCallback,
getIntersectionObserverEntry,
useIntersectionObserver,
} from '../../hooks/useIntersectionObserver';
return;
}
if (isRoomId(mentionId) && mx.getRoom(mentionId)) {
- if (mx.getRoom(mentionId)?.isSpaceRoom()) selectSpace(mentionId);
+ if (mx.getRoom(mentionId)?.isSpaceRoom()) selectTab(mentionId);
else selectRoom(mentionId);
return;
}
useCallback(() => roomInputRef.current, [roomInputRef])
);
- const handleAtBottomIntersection: OnIntersectionCallback = useCallback((entries) => {
- const target = atBottomAnchorRef.current;
- if (!target) return;
- const targetEntry = getIntersectionObserverEntry(target, entries);
-
- setAtBottom(targetEntry?.isIntersecting === true);
- }, []);
+ const debounceSetAtBottom = useDebounce(
+ useCallback((entry: IntersectionObserverEntry) => {
+ if (!entry.isIntersecting) setAtBottom(false);
+ }, []),
+ { wait: 1000 }
+ );
useIntersectionObserver(
- useDebounce(handleAtBottomIntersection, {
- wait: 200,
- }),
- useMemo(
+ useCallback(
+ (entries) => {
+ const target = atBottomAnchorRef.current;
+ if (!target) return;
+ const targetEntry = getIntersectionObserverEntry(target, entries);
+ if (targetEntry) debounceSetAtBottom(targetEntry);
+ if (targetEntry?.isIntersecting) setAtBottom(true);
+ },
+ [debounceSetAtBottom]
+ ),
+ useCallback(
() => ({
root: getScrollElement(),
rootMargin: '100px',