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

Function useAppendCommunitySuffix

lib/utils/drawer-utils.react.js:88–106  ·  view source on GitHub ↗
(
  communities: $ReadOnlyArray<ResolvedThreadInfo>,
)

Source from the content-addressed store, hash-verified

86}
87
88function useAppendCommunitySuffix(
89 communities: $ReadOnlyArray<ResolvedThreadInfo>,
90): $ReadOnlyArray<ResolvedThreadInfo> {
91 return React.useMemo(() => {
92 const result: ResolvedThreadInfo[] = [];
93 const names = new Map<string, number>();
94
95 for (const chat of communities) {
96 let name = chat.uiName;
97 const numberOfOccurrences = names.get(name);
98 names.set(name, (numberOfOccurrences ?? 0) + 1);
99 if (numberOfOccurrences) {
100 name = `${name} (${numberOfOccurrences.toString()})`;
101 }
102 result.push({ ...chat, uiName: name });
103 }
104 return result;
105 }, [communities]);
106}
107
108function filterThreadIDsBelongingToCommunity(
109 communityID: string,

Callers 3

CommunityDrawerContentFunction · 0.90

Calls 4

pushMethod · 0.80
getMethod · 0.65
toStringMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected