fix: ensures versions createdAt matches the original doc

This commit is contained in:
Jarrod Flesch
2023-02-13 11:03:12 -05:00
parent c975a6c8ba
commit 8c7e37c56a

View File

@@ -79,7 +79,7 @@ export const saveVersion = async ({
const data: Record<string, unknown> = {
autosave: Boolean(autosave),
version: versionData,
createdAt: draft ? now : new Date(doc.createdAt).toISOString(),
createdAt: doc?.createdAt ? new Date(doc.createdAt).toISOString() : now,
updatedAt: draft ? now : new Date(doc.updatedAt).toISOString(),
};
if (collection) data.parent = id;