Page MenuHomePhabricator

D13831.id45481.diff
No OneTemporary

D13831.id45481.diff

diff --git a/lib/hooks/message-hooks.js b/lib/hooks/message-hooks.js
--- a/lib/hooks/message-hooks.js
+++ b/lib/hooks/message-hooks.js
@@ -4,11 +4,15 @@
import { useGetLatestMessageEdit } from './latest-message-edit.js';
import { messageInfoSelector } from '../selectors/chat-selectors.js';
-import { getOldestNonLocalMessageID } from '../shared/message-utils.js';
+import {
+ getOldestNonLocalMessageID,
+ useFetchMessages,
+} from '../shared/message-utils.js';
import { messageSpecs } from '../shared/messages/message-specs.js';
import type { MessageInfo } from '../types/message-types.js';
import type { ThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js';
import { useSelector } from '../utils/redux-utils.js';
+import sleep from '../utils/sleep.js';
function useOldestMessageServerID(threadID: string): ?string {
return useSelector(state =>
@@ -107,6 +111,24 @@
})();
}, [threadInfo, getMessageInfoForPreview]);
+ const shouldFetchOlderMessages =
+ !!messageInfoForPreview?.shouldFetchOlderMessages;
+
+ const [canFetchOlderMessages, setCanFetchOlderMessages] =
+ React.useState(true);
+ const fetchMessages = useFetchMessages(threadInfo);
+ React.useEffect(() => {
+ if (!canFetchOlderMessages || !shouldFetchOlderMessages) {
+ return;
+ }
+ setCanFetchOlderMessages(false);
+ void (async () => {
+ await fetchMessages();
+ await sleep(3000);
+ setCanFetchOlderMessages(true);
+ })();
+ }, [canFetchOlderMessages, shouldFetchOlderMessages, fetchMessages]);
+
return messageInfoForPreview?.messageInfoForPreview;
}

File Metadata

Mime Type
text/plain
Expires
Thu, Oct 31, 5:18 PM (20 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2393451
Default Alt Text
D13831.id45481.diff (1 KB)

Event Timeline