Fix-jump-latest-senstivity (#1440)

* fix jump to latest sensitivity

* select mention space as tab
This commit is contained in:
Ajay Bura 2023-10-08 00:09:43 +11:00 committed by GitHub
parent 13573f4b3f
commit bffd27ae5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 15 deletions

View file

@ -319,7 +319,7 @@ export const useVirtualPaginator = <TScrollElement extends HTMLElement>(
const intersectionObserver = useIntersectionObserver( const intersectionObserver = useIntersectionObserver(
handlePaginatorElIntersection, handlePaginatorElIntersection,
useMemo( useCallback(
() => ({ () => ({
root: getScrollElement(), root: getScrollElement(),
}), }),

View file

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