Skip to content

Commit

Permalink
Add (un)publish notifications; skip some notification spam
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsnell committed Jul 1, 2020
1 parent 5b13a06 commit 1baaf0a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lib/state/simperium/functions/change-announcer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>(original?.tags || []);
const newTags = new Set<string>(note.tags);
Expand All @@ -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',
Expand Down

0 comments on commit 1baaf0a

Please sign in to comment.