Page MenuHomePhabricator

D14137.diff
No OneTemporary

D14137.diff

diff --git a/lib/hooks/latest-message-edit.js b/lib/hooks/latest-message-edit.js
--- a/lib/hooks/latest-message-edit.js
+++ b/lib/hooks/latest-message-edit.js
@@ -3,7 +3,7 @@
import * as React from 'react';
import { messageTypes } from '../types/message-types-enum.js';
-import type { RawMessageInfo } from '../types/message-types.js';
+import type { RawMessageInfo, MessageStore } from '../types/message-types.js';
import { getConfig } from '../utils/config.js';
import { translateClientDBMessageInfoToRawMessageInfo } from '../utils/message-ops-utils.js';
import { useSelector } from '../utils/redux-utils.js';
@@ -11,10 +11,21 @@
function useGetLatestMessageEdit(): (
messageID: string,
) => Promise<?RawMessageInfo> {
- const { getRelatedMessages } = getConfig().sqliteAPI;
const messageStore = useSelector(state => state.messageStore);
+ const baseGetLatestMessageEdit = useBaseGetLatestMessageEdit();
+ return React.useCallback(
+ (messageID: string) => baseGetLatestMessageEdit(messageID, messageStore),
+ [baseGetLatestMessageEdit, messageStore],
+ );
+}
+
+function useBaseGetLatestMessageEdit(): (
+ messageID: string,
+ messageStore: MessageStore,
+) => Promise<?RawMessageInfo> {
+ const { getRelatedMessages } = getConfig().sqliteAPI;
return React.useCallback(
- async (messageID: string) => {
+ async (messageID: string, messageStore: MessageStore) => {
const relatedDBMessages = await getRelatedMessages(messageID);
const relatedMessages = relatedDBMessages.map(
translateClientDBMessageInfoToRawMessageInfo,
@@ -76,8 +87,8 @@
return editedOriginalMessage;
},
- [getRelatedMessages, messageStore.messages, messageStore.threads],
+ [getRelatedMessages],
);
}
-export { useGetLatestMessageEdit };
+export { useGetLatestMessageEdit, useBaseGetLatestMessageEdit };
diff --git a/lib/hooks/thread-time.js b/lib/hooks/thread-time.js
--- a/lib/hooks/thread-time.js
+++ b/lib/hooks/thread-time.js
@@ -2,7 +2,7 @@
import * as React from 'react';
-import { useGetLatestMessageEdit } from './latest-message-edit.js';
+import { useBaseGetLatestMessageEdit } from './latest-message-edit.js';
import { messageSpecs } from '../shared/messages/message-specs.js';
import type {
MessageInfo,
@@ -19,7 +19,7 @@
messages: { +[id: string]: ?MessageInfo | RawMessageInfo },
) => LastUpdatedTimes {
const viewerID = useSelector(state => state.currentUserInfo?.id);
- const fetchMessage = useGetLatestMessageEdit();
+ const baseGetLatestMessageEdit = useBaseGetLatestMessageEdit();
return React.useCallback(
(threadInfo, messageStore, messages) => {
// This callback returns two variables:
@@ -47,7 +47,8 @@
const getLastUpdatedTimeParams = {
threadInfo,
viewerID,
- fetchMessage,
+ fetchMessage: (messageID: string) =>
+ baseGetLatestMessageEdit(messageID, messageStore),
};
let lastUpdatedTime: ?() => Promise<?number>;
@@ -126,7 +127,7 @@
lastUpdatedTime: lastUpdatedWithFallback,
};
},
- [viewerID, fetchMessage],
+ [viewerID, baseGetLatestMessageEdit],
);
}

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 2:04 AM (18 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2693161
Default Alt Text
D14137.diff (3 KB)

Event Timeline