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

Function reorderThreadSearchResults

lib/shared/thread-utils.js:1438–1460  ·  view source on GitHub ↗
(
  threadInfos: $ReadOnlyArray<T>,
  threadSearchResults: $ReadOnlyArray<string>,
)

Source from the content-addressed store, hash-verified

1436}
1437
1438function reorderThreadSearchResults<T: RawThreadInfo | ThreadInfo>(
1439 threadInfos: $ReadOnlyArray<T>,
1440 threadSearchResults: $ReadOnlyArray<string>,
1441): T[] {
1442 const privateThreads = [];
1443 const personalThreads = [];
1444 const otherThreads = [];
1445 const threadSearchResultsSet = new Set(threadSearchResults);
1446 for (const threadInfo of threadInfos) {
1447 if (!threadSearchResultsSet.has(threadInfo.id)) {
1448 continue;
1449 }
1450 if (threadTypeIsPrivate(threadInfo.type)) {
1451 privateThreads.push(threadInfo);
1452 } else if (threadTypeIsPersonal(threadInfo.type)) {
1453 personalThreads.push(threadInfo);
1454 } else {
1455 otherThreads.push(threadInfo);
1456 }
1457 }
1458
1459 return [...privateThreads, ...personalThreads, ...otherThreads];
1460}
1461
1462function useAvailableThreadMemberActions(
1463 memberInfo: RelativeMemberInfo,

Callers 3

ThreadPickerModalFunction · 0.90

Calls 4

threadTypeIsPrivateFunction · 0.90
threadTypeIsPersonalFunction · 0.90
pushMethod · 0.80
hasMethod · 0.65

Tested by

no test coverage detected