From e2213dbfa233fecb2bffe5325cc17b0b8fe7b975 Mon Sep 17 00:00:00 2001 From: feingold-ant Date: Mon, 15 Jul 2024 19:56:43 -0400 Subject: [PATCH] If a document is created within a collection, publish it automatically. (#7243) * If a document is created within a collection, publish it automatically. * automatically publish from app, not server * remove auto publish from server * New draft -> New doc --- app/scenes/DocumentNew.tsx | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/app/scenes/DocumentNew.tsx b/app/scenes/DocumentNew.tsx index 49bcc1b8e8..f9cb5a7953 100644 --- a/app/scenes/DocumentNew.tsx +++ b/app/scenes/DocumentNew.tsx @@ -41,17 +41,21 @@ function DocumentNew({ template }: Props) { if (id) { collection = await collections.fetch(id); } - const document = await documents.create({ - collectionId: collection?.id, - parentDocumentId, - fullWidth: - parentDocument?.fullWidth || - user.getPreference(UserPreference.FullWidthDocuments), - templateId: query.get("templateId") ?? undefined, - template, - title: "", - data: ProsemirrorHelper.getEmptyDocument(), - }); + const document = await documents.create( + { + collectionId: collection?.id, + parentDocumentId, + fullWidth: + parentDocument?.fullWidth || + user.getPreference(UserPreference.FullWidthDocuments), + templateId: query.get("templateId") ?? undefined, + template, + title: "", + data: ProsemirrorHelper.getEmptyDocument(), + }, + { publish: collection?.id || parentDocumentId ? true : undefined } + ); + history.replace( template || !user.separateEditMode ? documentPath(document)