Skip to content

Commit

Permalink
[web] Fix fetching messages in messages list
Browse files Browse the repository at this point in the history
Summary:
When there were more than 40 messages in a thick thread, fetching more messages sometimes resulted in fetching more batches at once and jumping back a multiple of 20 messages. This issue was caused by an old bugfix that was fixing an issue where an empty space was displayed after opening a thread, when it had more than 20 messages 0639b76. The solution to this is to apply this bugfix only when we initially open the page - this can be tested by checking if a scroll position is 0.

https://linear.app/comm/issue/ENG-9097/fetching-new-messages-in-message-list-is-glitchy-when-it-happens

Test Plan:
Created a thread with 200 messages. Tested on Chrome and Safari.
1. Opened the web page and scrolled slowly near every 20th messages. The original issue happened about 50% of the times, so I made sure to test it a couple of times. Didn't experience any glitches.
2. Zoomed out so that more than 20 messages can be seen at once and opened the web app. Immediately after opening the app more messages were fetched.

Reviewers: kamil, inka, ashoat

Reviewed By: ashoat

Differential Revision: https://phab.comm.dev/D13634
  • Loading branch information
palys-swm committed Oct 10, 2024
1 parent 1f91ed7 commit 77102c8
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions web/chat/chat-message-list.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ import {
threadOtherMembers,
} from 'lib/shared/thread-utils.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import {
threadTypeIsPersonal,
threadTypeIsThick,
} from 'lib/types/thread-types-enum.js';
import sleep from 'lib/utils/sleep.js';
import { threadTypeIsPersonal } from 'lib/types/thread-types-enum.js';

import { defaultMaxTextAreaHeight, editBoxHeight } from './chat-constants.js';
import css from './chat-message-list.css';
Expand Down Expand Up @@ -122,7 +118,11 @@ class ChatMessageList extends React.PureComponent<Props, State> {
const prevMessageListData = prevProps.messageListData;

const { messageContainer } = this;
if (messageContainer && prevMessageListData !== messageListData) {
if (
messageContainer &&
prevMessageListData !== messageListData &&
messageContainer.scrollTop === 0
) {
this.onScroll();
}

Expand Down Expand Up @@ -382,9 +382,6 @@ class ChatMessageList extends React.PureComponent<Props, State> {
this.loadingFromScroll = true;

try {
if (threadTypeIsThick(this.props.threadInfo.type)) {
await sleep(100);
}
await this.props.fetchMessages();
} finally {
this.loadingFromScroll = false;
Expand Down

0 comments on commit 77102c8

Please sign in to comment.