From 1baaf0aa01609b4e55a05df956f7b206b93d9af3 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Wed, 1 Jul 2020 00:45:46 -0700 Subject: [PATCH] Add (un)publish notifications; skip some notification spam --- .../simperium/functions/change-announcer.ts | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/lib/state/simperium/functions/change-announcer.ts b/lib/state/simperium/functions/change-announcer.ts index fcff00a1b..c73a6b207 100644 --- a/lib/state/simperium/functions/change-announcer.ts +++ b/lib/state/simperium/functions/change-announcer.ts @@ -86,6 +86,27 @@ export const announceNoteUpdates = ({ dispatch }: S.Store) => { return; } + if (!original?.publishURL && note.publishURL?.length) { + noteIfy( + noteId, + 'Note Published', + note.content.slice(0, 200) || '(no content)' + ); + return; + } + + if ( + original?.systemTags?.includes('published') && + !note.systemTags.includes('published') + ) { + noteIfy( + noteId, + 'Note Unpublished', + note.content.slice(0, 200) || '(no content)' + ); + return; + } + if (patch.tags && !patch.content) { const oldTags = new Set(original?.tags || []); const newTags = new Set(note.tags); @@ -111,6 +132,25 @@ export const announceNoteUpdates = ({ dispatch }: S.Store) => { return; } + // other publish events are covered by the earlier checks + if ( + Object.getOwnPropertyNames(patch).length === 1 && + ((patch.systemTags && + original?.systemTags.includes('published') !== + note.systemTags.includes('published')) || + patch.publishURL) + ) { + return; + } + + // ignore pinned and markdown and other system tag changes + if ( + Object.getOwnPropertyNames(patch).length === 1 && + patch.systemTags + ) { + return; + } + noteIfy( noteId, 'Note Updated',