fix: Remove vestigial done flag from document updates (#14561)

Creating a revision immediately when the user clicks Done raced the collaboration server's save debounce, producing a stale revision followed by a second one and duplicate Slack notifications.
This commit is contained in:
Tom Moor authored and GitHub committed 2026-11-12 18:57:50 -05:00
1 parent 72a72dc735
commit d066c98bde
4 files changed
+7 -25

No files matched your search

-1
View File
@@ -41,7 +41,6 @@ import type { Searchable } from "./interfaces/Searchable";
type SaveOptions = JSONObject & {
publish?: boolean;
done?: boolean;
autosave?: boolean;
};
+4 -1
View File
@@ -165,7 +165,10 @@ export function useDocumentSave({
setIsPublishing(!!options.publish);
try {
const savedDocument = await document.save(undefined, options);
const savedDocument = await document.save(undefined, {
publish: options.publish,
autosave: options.autosave,
});
isEditorDirtyRef.current = false;
setIsEditorDirty(false);
+3 -20
View File
@@ -1,6 +1,6 @@
import type { DocumentPreferences, TextEditMode } from "@shared/types";
import { DocumentConflictError, ValidationError } from "@server/errors";
import { Event, Document } from "@server/models";
import { Document } from "@server/models";
import { DocumentHelper } from "@server/models/helpers/DocumentHelper";
import { TextHelper } from "@server/models/helpers/TextHelper";
import type { APIContext } from "@server/types";
@@ -16,8 +16,6 @@ type Props = {
color?: string | null;
/** The new text content */
text?: string;
/** Whether the editing session is complete */
done?: boolean;
/** The version of the client editor that was used */
editorVersion?: string;
/** The ID of the template that was used */
@@ -68,7 +66,6 @@ export default async function documentUpdater(
publish,
collectionId,
deprecatedReason,
done,
}: Props
): Promise<Document> {
const { user } = ctx.state.auth;
@@ -138,31 +135,17 @@ export default async function documentUpdater(
}
const changed = document.changed();
const eventData = done !== undefined ? { done } : undefined;
const { collection } = document;
const event = {
name: "documents.update",
documentId: document.id,
collectionId: cId,
data: eventData,
};
if (publish && cId) {
if (!document.collectionId) {
document.collectionId = cId;
}
await document.publish(ctx, { collectionId: cId, data: eventData });
await document.publish(ctx, { collectionId: cId });
} else if (changed) {
document.lastModifiedById = user.id;
document.updatedBy = user;
await document.saveWithCtx(ctx, undefined, { data: eventData });
} else if (done) {
await Event.schedule({
...event,
actorId: user.id,
teamId: document.teamId,
});
await document.saveWithCtx(ctx);
}
// Publishing can move the document to another collection, and the save
-3
View File
@@ -450,9 +450,6 @@ export const DocumentsUpdateSchema = BaseSchema.extend({
/** @deprecated Version of the API to be used, remove in a few releases */
apiVersion: z.number().optional(),
/** Whether the editing session is complete */
done: z.boolean().optional(),
}),
})
.refine(