diff --git a/app/models/Document.ts b/app/models/Document.ts index f15088771b..b6697be3a3 100644 --- a/app/models/Document.ts +++ b/app/models/Document.ts @@ -41,7 +41,6 @@ import type { Searchable } from "./interfaces/Searchable"; type SaveOptions = JSONObject & { publish?: boolean; - done?: boolean; autosave?: boolean; }; diff --git a/app/scenes/Document/hooks/useDocumentSave.ts b/app/scenes/Document/hooks/useDocumentSave.ts index 5181d4047c..ba30a17bf6 100644 --- a/app/scenes/Document/hooks/useDocumentSave.ts +++ b/app/scenes/Document/hooks/useDocumentSave.ts @@ -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); diff --git a/server/commands/documentUpdater.ts b/server/commands/documentUpdater.ts index 1fb618a069..0436b0dea0 100644 --- a/server/commands/documentUpdater.ts +++ b/server/commands/documentUpdater.ts @@ -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 { 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 diff --git a/server/routes/api/documents/schema.ts b/server/routes/api/documents/schema.ts index 4948645c95..149aa5415c 100644 --- a/server/routes/api/documents/schema.ts +++ b/server/routes/api/documents/schema.ts @@ -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(