Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3334363
D13912.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
D13912.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D13912: [lib] Extract getLastUpdatedTime to a separate file
Attached
Detach File
Event Timeline
Log In to Comment