Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3104395
D13831.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D13831.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 31, 5:16 PM (20 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2393451
Default Alt Text
D13831.diff (1 KB)
Attached To
Mode
D13831: [lib] Fetch older messages when showInMessagePreview rejects messages in local store
Attached
Detach File
Event Timeline
Log In to Comment