diff --git a/app/assets/javascripts/components/NotesOptions.tsx b/app/assets/javascripts/components/NotesOptions.tsx index f3dcb9865..11a928da6 100644 --- a/app/assets/javascripts/components/NotesOptions.tsx +++ b/app/assets/javascripts/components/NotesOptions.tsx @@ -8,6 +8,7 @@ import { DisclosureButton, DisclosurePanel, } from '@reach/disclosure'; +import { SNNote } from '@standardnotes/snjs/dist/@types'; type Props = { appState: AppState; @@ -25,12 +26,21 @@ export const NotesOptions = observer( right: 0, }); + const toggleOn = (condition: (note: SNNote) => boolean) => { + const notesMatchingAttribute = notes.filter(condition); + const notesNotMatchingAttribute = notes.filter((note) => !condition(note)); + return (notesMatchingAttribute.length > notesNotMatchingAttribute.length); + }; + const notes = Object.values(appState.notes.selectedNotes); - const hidePreviews = notes.some((note) => note.hidePreview); - const locked = notes.some((note) => note.locked); + const hidePreviews = toggleOn(note => note.hidePreview); + const locked = toggleOn(note => note.locked); const archived = notes.some((note) => note.archived); + const unarchived = notes.some((note) => !note.archived); const trashed = notes.some((note) => note.trashed); + const notTrashed = notes.some((note) => !note.trashed); const pinned = notes.some((note) => note.pinned); + const unpinned = notes.some((note) => !note.pinned); const tagsButtonRef = useRef(); @@ -141,48 +151,90 @@ export const NotesOptions = observer( )} - - - + {unpinned && ( + + )} + {pinned && ( + + )} + {unarchived && ( + + )} + {archived && ( + + )} + {notTrashed && ( + + )} + {trashed && ( + + )} {appState.selectedTag?.isTrashTag && ( )}