Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove useLegacyThreadMessageJump #35636

Merged
merged 3 commits into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useMergedRefs } from '@rocket.chat/fuselage-hooks';
import { useSetting, useUserPreference } from '@rocket.chat/ui-contexts';
import { differenceInSeconds } from 'date-fns';
import type { ReactElement } from 'react';
import { Fragment } from 'react';
import { Fragment, useRef } from 'react';
import { useTranslation } from 'react-i18next';

import { ThreadMessageItem } from './ThreadMessageItem';
Expand All @@ -18,7 +18,6 @@ import LoadingMessagesIndicator from '../../../body/LoadingMessagesIndicator';
import { useDateScroll } from '../../../hooks/useDateScroll';
import { useFirstUnreadMessageId } from '../../../hooks/useFirstUnreadMessageId';
import { useMessageListNavigation } from '../../../hooks/useMessageListNavigation';
import { useLegacyThreadMessageJump } from '../hooks/useLegacyThreadMessageJump';
import { useLegacyThreadMessageListScrolling } from '../hooks/useLegacyThreadMessageListScrolling';
import { useLegacyThreadMessages } from '../hooks/useLegacyThreadMessages';
import './threads.css';
Expand Down Expand Up @@ -55,22 +54,23 @@ const ThreadMessageList = ({ mainMessage }: ThreadMessageListProps): ReactElemen
const { innerRef, bubbleRef, listStyle, ...bubbleDate } = useDateScroll();

const { messages, loading } = useLegacyThreadMessages(mainMessage._id);

const {
listWrapperRef: listWrapperScrollRef,
listRef: listScrollRef,
onScroll: handleScroll,
} = useLegacyThreadMessageListScrolling(mainMessage);
const { parentRef: listJumpRef } = useLegacyThreadMessageJump({ enabled: !loading });

const hideUsernames = useUserPreference<boolean>('hideUsernames');
const showUserAvatar = !!useUserPreference<boolean>('displayAvatars');
const firstUnreadMessageId = useFirstUnreadMessageId();
const messageGroupingPeriod = useSetting('Message_GroupingPeriod', 300);

const { messageListRef } = useMessageListNavigation();
const listRef = useMergedRefs<HTMLElement | null>(listScrollRef, messageListRef);

const scrollRef = useMergedRefs<HTMLElement | null>(innerRef, listWrapperScrollRef, listJumpRef);
const ref = useRef<HTMLElement | null>(null);
const listRef = useMergedRefs<HTMLElement | null>(listScrollRef, messageListRef);
const scrollRef = useMergedRefs<HTMLElement | null>(innerRef, listWrapperScrollRef, ref);

return (
<div className={['thread-list js-scroll-thread', hideUsernames && 'hide-usernames'].filter(isTruthy).join(' ')}>
Expand All @@ -88,7 +88,7 @@ const ThreadMessageList = ({ mainMessage }: ThreadMessageListProps): ReactElemen
<LoadingMessagesIndicator />
</li>
) : (
<MessageListProvider messageListRef={listJumpRef}>
<MessageListProvider messageListRef={ref}>
{[mainMessage, ...messages].map((message, index, { [index - 1]: previous }) => {
const sequential = isMessageSequential(message, previous, messageGroupingPeriod);
const newDay = isMessageNewDay(message, previous);
Expand Down

This file was deleted.

Loading