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(soup): use sortTs for email thread ordering and display (#2238)

Evan Hutnik0747e1c1a7a2
diff --git a/js/app/packages/app/component/next-soup/soup-view/sort-options.tsx b/js/app/packages/app/component/next-soup/soup-view/sort-options.tsx
index 3ccc0f245a..4ba57135e5 100644
--- a/js/app/packages/app/component/next-soup/soup-view/sort-options.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/sort-options.tsx
@@ -52,15 +52,15 @@ export function sortByNotifiedAt<T extends WithNotification<EntityData>>(
}
export function sortByCreatedAt<T extends EntityData>(a: T, b: T): number {
- return compareDateDesc(a.createdAt, b.createdAt);
+ return compareDateDesc(a.sortTs ?? a.createdAt, b.sortTs ?? b.createdAt);
}
export function sortByUpdatedAt<T extends EntityData>(a: T, b: T) {
- return compareDateDesc(a.updatedAt, b.updatedAt);
+ return compareDateDesc(a.sortTs ?? a.updatedAt, b.sortTs ?? b.updatedAt);
}
export function sortByViewedAt<T extends EntityData>(a: T, b: T) {
- return compareDateDesc(a.viewedAt, b.viewedAt);
+ return compareDateDesc(a.sortTs ?? a.viewedAt, b.sortTs ?? b.viewedAt);
}
export function sortByFrecencyScore<T extends EntityData>(a: T, b: T): number {
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
index d209684188..5019ef5074 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
@@ -791,6 +791,8 @@ export const SoupViewList = (props: SoupViewListProps) => {
>
{(row, i) => {
const timestamp = () => {
+ if (row.original.sortTs) return row.original.sortTs;
+
const sort_ = soup.sort.active();
if (!sort_.length) return;
diff --git a/js/app/packages/entity/src/extractors/entity-timestamp.tsx b/js/app/packages/entity/src/extractors/entity-timestamp.tsx
index 94c1c5844e..57f250c9e7 100644
--- a/js/app/packages/entity/src/extractors/entity-timestamp.tsx
+++ b/js/app/packages/entity/src/extractors/entity-timestamp.tsx
@@ -8,6 +8,7 @@ export function EntityTimestamp(props: {
}) {
const timestamp = () => {
if (props.overrideTimeStamp) return props.overrideTimeStamp;
+ if (props.entity.sortTs) return props.entity.sortTs;
if (props.entity.updatedAt) return props.entity.updatedAt;
return new Date();
};
diff --git a/js/app/packages/entity/src/types/entity.ts b/js/app/packages/entity/src/types/entity.ts
index 64a907e134..f3527a9b01 100644
--- a/js/app/packages/entity/src/types/entity.ts
+++ b/js/app/packages/entity/src/types/entity.ts
@@ -15,6 +15,7 @@ export type EntityBase = {
createdAt?: DateValue | null;
updatedAt?: DateValue | null;
viewedAt?: DateValue | null;
+ sortTs?: DateValue | null;
};
export type ChannelEntity = EntityBase & {
diff --git a/js/app/packages/queries/soup/transform-utils.ts b/js/app/packages/queries/soup/transform-utils.ts
index 4195101a77..b1f8e02c36 100644
--- a/js/app/packages/queries/soup/transform-utils.ts
+++ b/js/app/packages/queries/soup/transform-utils.ts
@@ -404,6 +404,7 @@ export const mapSoupPageToEntityList: (
...item.data,
createdAt: item.data.createdAt,
updatedAt: item.data.updatedAt,
+ sortTs: item.data.sortTs,
senderEmail: item.data.senderEmail ?? undefined,
senderName: item.data.senderName ?? undefined,
snippet: item.data.snippet ?? undefined,