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.

chg(unified-list): use backend for task filtering in list (#2064)

teo423549572a0f
diff --git a/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts b/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts
index ac6cdfed14..9fbb7e3f39 100644
--- a/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts
+++ b/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts
@@ -182,7 +182,10 @@ export const VIEW_TAB_PRESETS: Record<ListView, ViewTabConfig> = {
return {
queryFilters: {
...QUERY_FILTERS.task,
- document_filters: { owners: [ctx.userId] },
+ document_filters: {
+ ...QUERY_FILTERS.task.document_filters,
+ owners: [ctx.userId],
+ },
},
clientFilters: { and: ['task', 'assigned-to'] },
};
@@ -192,7 +195,10 @@ export const VIEW_TAB_PRESETS: Record<ListView, ViewTabConfig> = {
return {
queryFilters: {
...QUERY_FILTERS.task,
- document_filters: { owners: [ctx.userId] },
+ document_filters: {
+ ...QUERY_FILTERS.task.document_filters,
+ owners: [ctx.userId],
+ },
},
clientFilters: { and: ['task'] },
};
diff --git a/js/app/packages/app/component/next-soup/filters/query-filters.ts b/js/app/packages/app/component/next-soup/filters/query-filters.ts
index b6a79fd651..64e6c355d9 100644
--- a/js/app/packages/app/component/next-soup/filters/query-filters.ts
+++ b/js/app/packages/app/component/next-soup/filters/query-filters.ts
@@ -22,7 +22,16 @@ function isIdFilteredOut(ids: string[] | undefined, value: string): boolean {
return !ids.includes(value);
}
-// TODO: this only supports for item type and id filters, other filters to be added later
+function isValueFilteredOut(
+ values: string[] | undefined,
+ value: string | null | undefined
+): boolean {
+ if (!values || values.length === 0) return false;
+ if (!value) return true;
+ return !values.includes(value);
+}
+
+// TODO: this only supports the subset of soup filters needed for cache matching.
export function filterSoupItemByRequestBody(
item: SoupApiItem,
body: SoupBody
@@ -31,7 +40,12 @@ export function filterSoupItemByRequestBody(
.with(
{ tag: 'document' },
({ data }) =>
- !isIdFilteredOut(body.document_filters?.document_ids, data.id)
+ !isIdFilteredOut(body.document_filters?.document_ids, data.id) &&
+ !isValueFilteredOut(body.document_filters?.owners, data.ownerId) &&
+ !isValueFilteredOut(
+ body.document_filters?.sub_types,
+ data.subType?.type
+ )
)
.with(
{ tag: 'chat' },
@@ -88,7 +102,7 @@ export const QUERY_FILTERS = {
chat_filters: { chat_ids: EXCLUDE },
email_filters: { recipients: EXCLUDE },
project_filters: { project_ids: EXCLUDE },
- document_filters: { file_types: ['md'] },
+ document_filters: { sub_types: ['task'] },
},
email: {