Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix: sort channel first iff name match (#778)

gbirmana83573891b22
diff --git a/js/app/packages/macro-entity/src/components/UnifiedInfiniteList.tsx b/js/app/packages/macro-entity/src/components/UnifiedInfiniteList.tsx
index 002fea0ed8..30d170ab24 100644
--- a/js/app/packages/macro-entity/src/components/UnifiedInfiniteList.tsx
+++ b/js/app/packages/macro-entity/src/components/UnifiedInfiniteList.tsx
@@ -159,9 +159,11 @@ const deduplicateEntities = <T extends EntityData>(entities: T[]): T[] => {
* Sorts entities for search mode
*/
const sortEntitiesForSearch = <T extends EntityData>(a: T, b: T): number => {
- const channelsFirst = (a: WithSearch<T>, b: WithSearch<T>) => {
- if (a.type === 'channel' && b.type !== 'channel') return -1;
- if (a.type !== 'channel' && b.type === 'channel') return 1;
+ const channelsWithNameMatchesFirst = (a: WithSearch<T>, b: WithSearch<T>) => {
+ if (a.type === 'channel' && b.type !== 'channel' && a.search.nameHighlight)
+ return -1;
+ if (a.type !== 'channel' && b.type === 'channel' && b.search.nameHighlight)
+ return 1;
return 0;
};
@@ -172,7 +174,7 @@ const sortEntitiesForSearch = <T extends EntityData>(a: T, b: T): number => {
};
if (isSearchEntity(a) && isSearchEntity(b)) {
- return channelsFirst(a, b) || localFirst(a, b);
+ return channelsWithNameMatchesFirst(a, b) || localFirst(a, b);
}
return 0;