Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33293624
D3351.1768743381.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D3351.1768743381.diff
View Options
diff --git a/web/chat/chat-message-list.react.js b/web/chat/chat-message-list.react.js
--- a/web/chat/chat-message-list.react.js
+++ b/web/chat/chat-message-list.react.js
@@ -11,6 +11,7 @@
fetchMessagesBeforeCursorActionTypes,
fetchMessagesBeforeCursor,
fetchMostRecentMessagesActionTypes,
+ fetchMostRecentMessages,
} from 'lib/actions/message-actions';
import { registerFetchKey } from 'lib/reducers/loading-reducer';
import {
@@ -62,6 +63,9 @@
threadID: string,
beforeMessageID: string,
) => Promise<FetchMessageInfosPayload>,
+ +fetchMostRecentMessages: (
+ threadID: string,
+ ) => Promise<FetchMessageInfosPayload>,
// withInputState
+inputState: ?InputState,
};
@@ -341,6 +345,7 @@
if (!this.messageContainer) {
return;
}
+
const { scrollTop, scrollHeight, clientHeight } = this.messageContainer;
if (
this.props.startReached ||
@@ -348,20 +353,27 @@
) {
return;
}
- const oldestMessageServerID = this.oldestMessageServerID();
- if (!oldestMessageServerID) {
- return;
- }
+
if (this.loadingFromScroll) {
return;
}
this.loadingFromScroll = true;
+
const threadID = this.props.activeChatThreadID;
invariant(threadID, 'should be set');
- this.props.dispatchActionPromise(
- fetchMessagesBeforeCursorActionTypes,
- this.props.fetchMessagesBeforeCursor(threadID, oldestMessageServerID),
- );
+
+ const oldestMessageServerID = this.oldestMessageServerID();
+ if (oldestMessageServerID) {
+ this.props.dispatchActionPromise(
+ fetchMessagesBeforeCursorActionTypes,
+ this.props.fetchMessagesBeforeCursor(threadID, oldestMessageServerID),
+ );
+ } else {
+ this.props.dispatchActionPromise(
+ fetchMostRecentMessagesActionTypes,
+ this.props.fetchMostRecentMessages(threadID),
+ );
+ }
}
oldestMessageServerID(): ?string {
@@ -441,6 +453,7 @@
const callFetchMessagesBeforeCursor = useServerCall(
fetchMessagesBeforeCursor,
);
+ const callFetchMostRecentMessages = useServerCall(fetchMostRecentMessages);
const inputState = React.useContext(InputStateContext);
const [dndProps, connectDropTarget] = useDrop({
@@ -478,6 +491,7 @@
inputState={inputState}
dispatchActionPromise={dispatchActionPromise}
fetchMessagesBeforeCursor={callFetchMessagesBeforeCursor}
+ fetchMostRecentMessages={callFetchMostRecentMessages}
{...dndProps}
connectDropTarget={connectDropTarget}
/>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 18, 1:36 PM (21 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5951856
Default Alt Text
D3351.1768743381.diff (2 KB)
Attached To
Mode
D3351: [web] Make ChatMessageList able to fetch messages if none are present
Attached
Detach File
Event Timeline
Log In to Comment