( messageStore: MessageStore, threadInfos: MixedRawThreadInfos, )
| 388 | ); |
| 389 | |
| 390 | function 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 | |
| 420 | const mostRecentlyReadThreadSelector: (state: BaseAppState<>) => ?string = |
| 421 | createSelector( |
nothing calls this directly
no test coverage detected