MCPcopy Create free account
hub / github.com/CommE2E/comm / mostRecentlyReadThread

Function mostRecentlyReadThread

lib/selectors/thread-selectors.js:390–418  ·  view source on GitHub ↗
(
  messageStore: MessageStore,
  threadInfos: MixedRawThreadInfos,
)

Source from the content-addressed store, hash-verified

388);
389
390function mostRecentlyReadThread(
391 messageStore: MessageStore,
392 threadInfos: MixedRawThreadInfos,
393): ?string {
394 let mostRecent = null;
395 for (const threadID in threadInfos) {
396 const threadInfo = threadInfos[threadID];
397 if (threadInfo.currentUser.unread) {
398 continue;
399 }
400 const threadMessageInfo = messageStore.threads[threadID];
401 if (!threadMessageInfo) {
402 continue;
403 }
404 const mostRecentMessageTime =
405 threadMessageInfo.messageIDs.length === 0
406 ? threadInfo.creationTime
407 : messageStore.messages[threadMessageInfo.messageIDs[0]].time;
408 if (mostRecent && mostRecent.time >= mostRecentMessageTime) {
409 continue;
410 }
411
412 const topLevelThreadID = threadTypeIsSidebar(threadInfo.type)
413 ? threadInfo.parentThreadID
414 : threadID;
415 mostRecent = { threadID: topLevelThreadID, time: mostRecentMessageTime };
416 }
417 return mostRecent ? mostRecent.threadID : null;
418}
419
420const mostRecentlyReadThreadSelector: (state: BaseAppState<>) => ?string =
421 createSelector(

Callers

nothing calls this directly

Calls 1

threadTypeIsSidebarFunction · 0.90

Tested by

no test coverage detected