Skip to content

Commit

Permalink
Revert "[lib] Extract getLastUpdatedTime to a separate file"
Browse files Browse the repository at this point in the history
This reverts commit 084e006.
  • Loading branch information
Ashoat committed Dec 10, 2024
1 parent d0de5a7 commit ed098ff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
25 changes: 0 additions & 25 deletions lib/hooks/thread-time.js

This file was deleted.

20 changes: 19 additions & 1 deletion lib/selectors/chat-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
threadInfoSelector,
} from './thread-selectors.js';
import { useSidebarInfos } from '../hooks/sidebar-hooks.js';
import { getLastUpdatedTime } from '../hooks/thread-time.js';
import {
createMessageInfo,
getMostRecentNonLocalMessageID,
Expand Down Expand Up @@ -93,6 +92,25 @@ function isEmptyMediaMessage(messageInfo: MessageInfo): boolean {
);
}

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();
Expand Down

0 comments on commit ed098ff

Please sign in to comment.