Page MenuHomePhabricator

D13912.diff
No OneTemporary

D13912.diff

diff --git a/lib/hooks/thread-time.js b/lib/hooks/thread-time.js
new file mode 100644
--- /dev/null
+++ b/lib/hooks/thread-time.js
@@ -0,0 +1,25 @@
+// @flow
+
+import type { MessageInfo, MessageStore } from '../types/message-types.js';
+import type { ThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js';
+
+function getLastUpdatedTime(
+ threadInfo: ThreadInfo,
+ messageStore: MessageStore,
+ messages: { +[id: string]: ?MessageInfo },
+): number {
+ const thread = messageStore.threads[threadInfo.id];
+ if (!thread) {
+ return threadInfo.creationTime;
+ }
+ for (const messageID of thread.messageIDs) {
+ const messageInfo = messages[messageID];
+ if (!messageInfo) {
+ continue;
+ }
+ return messageInfo.time;
+ }
+ return threadInfo.creationTime;
+}
+
+export { getLastUpdatedTime };
diff --git a/lib/selectors/chat-selectors.js b/lib/selectors/chat-selectors.js
--- a/lib/selectors/chat-selectors.js
+++ b/lib/selectors/chat-selectors.js
@@ -14,6 +14,7 @@
threadInfoSelector,
} from './thread-selectors.js';
import { useSidebarInfos } from '../hooks/sidebar-hooks.js';
+import { getLastUpdatedTime } from '../hooks/thread-time.js';
import {
createMessageInfo,
getMostRecentNonLocalMessageID,
@@ -92,25 +93,6 @@
);
}
-function getLastUpdatedTime(
- threadInfo: ThreadInfo,
- messageStore: MessageStore,
- messages: { +[id: string]: ?MessageInfo },
-): number {
- const thread = messageStore.threads[threadInfo.id];
- if (!thread) {
- return threadInfo.creationTime;
- }
- for (const messageID of thread.messageIDs) {
- const messageInfo = messages[messageID];
- if (!messageInfo || isEmptyMediaMessage(messageInfo)) {
- continue;
- }
- return messageInfo.time;
- }
- return threadInfo.creationTime;
-}
-
function useCreateChatThreadItem(): ThreadInfo => ChatThreadItem {
const messageInfos = useSelector(messageInfoSelector);
const sidebarInfos = useSidebarInfos();

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 6:53 AM (19 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2532311
Default Alt Text
D13912.diff (1 KB)

Event Timeline