Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

fix attachments order

Pedro Ladeiraf0516573eeee
diff --git a/apps/web/lib/messages/utils.ts b/apps/web/lib/messages/utils.ts
index edbf8ddc75..591a706c83 100644
--- a/apps/web/lib/messages/utils.ts
+++ b/apps/web/lib/messages/utils.ts
@@ -29,11 +29,12 @@ export function mapMessageAttachmentsForCreate(
}
export function sortMessageAttachments<
- T extends { createdAt: Date; id: string },
+ T extends { createdAt: Date | string; id: string },
>(attachments: T[]) {
return [...attachments].sort(
(a, b) =>
- a.createdAt.getTime() - b.createdAt.getTime() || a.id.localeCompare(b.id),
+ +new Date(a.createdAt) - +new Date(b.createdAt) ||
+ a.id.localeCompare(b.id),
);
}