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

Revert "[CP Staging] Chat is not scrolled to the new message on a newly created WS chat after whisper message" #41302

Merged
merged 1 commit into from
Apr 30, 2024
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
12 changes: 4 additions & 8 deletions src/hooks/useReportScrollManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@ function useReportScrollManager(): ReportScrollManagerData {
* Scroll to the bottom of the flatlist.
*/
const scrollToBottom = useCallback(() => {
// We're deferring execution here because on iOS: mWeb (WebKit based browsers)
// scrollToOffset method doesn't work unless called on the next tick
requestAnimationFrame(() => {
if (!flatListRef?.current) {
return;
}
if (!flatListRef?.current) {
return;
}

flatListRef.current.scrollToOffset({animated: false, offset: 0});
});
flatListRef.current.scrollToOffset({animated: false, offset: 0});
}, [flatListRef]);

return {ref: flatListRef, scrollToIndex, scrollToBottom};
Expand Down
10 changes: 4 additions & 6 deletions src/pages/home/report/ReportActionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,16 +325,14 @@ function ReportActionsList({

const scrollToBottomForCurrentUserAction = useCallback(
(isFromCurrentUser: boolean) => {
// If a new comment is added and it's from the current user scroll to the bottom
// otherwise leave the user positioned where they are now in the list.
// Additionally, since the first report action could be a whisper message (new WS) ->
// hasNewestReportAction will be false, check isWhisperAction is false before returning early.
if (!isFromCurrentUser || (!hasNewestReportActionRef.current && !ReportActionsUtils.isWhisperAction(sortedReportActions?.[0]))) {
// If a new comment is added and it's from the current user scroll to the bottom otherwise leave the user positioned where
// they are now in the list.
if (!isFromCurrentUser || !hasNewestReportActionRef.current) {
return;
}
InteractionManager.runAfterInteractions(() => reportScrollManager.scrollToBottom());
},
[sortedReportActions, reportScrollManager],
[reportScrollManager],
);
useEffect(() => {
// Why are we doing this, when in the cleanup of the useEffect we are already calling the unsubscribe function?
Expand Down
Loading