From 3eb67eaecf25315342a75c2c0c7c93e290a1f762 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 23 Apr 2019 20:54:24 -0700 Subject: [PATCH] Fixes: Calm notifications when hitting CMD+S while editing --- server/api/documents.js | 3 ++- server/events.js | 1 + server/services/notifications.js | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/server/api/documents.js b/server/api/documents.js index fb3e2681b..e890e0c67 100644 --- a/server/api/documents.js +++ b/server/api/documents.js @@ -600,7 +600,7 @@ router.post('documents.create', auth(), async ctx => { }); router.post('documents.update', auth(), async ctx => { - const { id, title, text, publish, autosave, lastRevision } = ctx.body; + const { id, title, text, publish, autosave, done, lastRevision } = ctx.body; ctx.assertPresent(id, 'id is required'); ctx.assertPresent(title || text, 'title or text is required'); @@ -638,6 +638,7 @@ router.post('documents.update', auth(), async ctx => { teamId: document.teamId, actorId: user.id, autosave, + done, }); } diff --git a/server/events.js b/server/events.js index d576d102f..e5c47f0b1 100644 --- a/server/events.js +++ b/server/events.js @@ -45,6 +45,7 @@ type DocumentEvent = teamId: string, actorId: string, autosave: boolean, + done: boolean, }; type CollectionEvent = diff --git a/server/services/notifications.js b/server/services/notifications.js index f5f0dcacb..22b53bc31 100644 --- a/server/services/notifications.js +++ b/server/services/notifications.js @@ -20,6 +20,9 @@ export default class Notifications { // lets not send a notification on every autosave update if (event.autosave) return; + // wait until the user has finished editing + if (!event.done) return; + const document = await Document.findById(event.modelId); if (!document) return;