From 9a9d2c408597a8371f8a9a18f73937159ef80383 Mon Sep 17 00:00:00 2001 From: Baptiste Grob <60621355+baptiste-grob@users.noreply.github.com> Date: Wed, 9 Sep 2020 16:56:38 +0200 Subject: [PATCH] fix: smart tags --- .../javascripts/views/editor/editor_view.ts | 2 +- .../javascripts/views/notes/note_utils.ts | 14 +------------- .../javascripts/views/notes/notes_view.ts | 19 +++++++------------ 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/app/assets/javascripts/views/editor/editor_view.ts b/app/assets/javascripts/views/editor/editor_view.ts index 72a87381f..5dee73bca 100644 --- a/app/assets/javascripts/views/editor/editor_view.ts +++ b/app/assets/javascripts/views/editor/editor_view.ts @@ -851,7 +851,7 @@ class EditorViewCtrl extends PureViewCtrl<{}, EditorState> { for (const tag of removeTags) { await this.application.changeItem(tag.uuid, (mutator) => { mutator.removeItemAsRelationship(note); - }) + }); } const newRelationships: SNTag[] = []; for (const title of strings) { diff --git a/app/assets/javascripts/views/notes/note_utils.ts b/app/assets/javascripts/views/notes/note_utils.ts index f87cb96ce..6d763ccef 100644 --- a/app/assets/javascripts/views/notes/note_utils.ts +++ b/app/assets/javascripts/views/notes/note_utils.ts @@ -13,7 +13,6 @@ export enum NoteSortKey { export function notePassesFilter( note: SNNote, - selectedTag: SNTag, showArchived: boolean, hidePinned: boolean, filterText: string @@ -21,17 +20,6 @@ export function notePassesFilter( let canShowArchived = showArchived; const canShowPinned = !hidePinned; - if (!selectedTag.isTrashTag && note.trashed) { - return false; - } - const isSmartTag = selectedTag.isSmartTag(); - if (isSmartTag) { - canShowArchived = ( - canShowArchived || - selectedTag.isArchiveTag || - selectedTag.isTrashTag - ); - } if ( (note.archived && !canShowArchived) || (note.pinned && !canShowPinned) @@ -79,4 +67,4 @@ function stringIsUuid(text: string) { ); // eslint-disable-next-line no-unneeded-ternary return matches ? true : false; -} \ No newline at end of file +} diff --git a/app/assets/javascripts/views/notes/notes_view.ts b/app/assets/javascripts/views/notes/notes_view.ts index 094de2822..06553c625 100644 --- a/app/assets/javascripts/views/notes/notes_view.ts +++ b/app/assets/javascripts/views/notes/notes_view.ts @@ -11,7 +11,6 @@ import { WebPrefKey, findInArray, CollectionSort, - SNSmartTag } from 'snjs'; import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl'; import { AppStateEvent } from '@/ui_models/app_state'; @@ -331,23 +330,19 @@ class NotesViewCtrl extends PureViewCtrl<{}, NotesState> { */ private reloadNotesDisplayOptions() { const tag = this.appState.selectedTag!; - this.application.setDisplayOptions( - ContentType.Note, - this.getState().sortBy! as CollectionSort, - this.getState().sortReverse! ? 'asc' : 'dsc', + this.application!.setNotesDisplayOptions( + tag, + this.state.sortBy! as CollectionSort, + this.state.sortReverse! ? 'asc' : 'dsc', (note: SNNote) => { - const matchesTag = tag.isSmartTag() - ? note.satisfiesPredicate((tag as SNSmartTag).predicate) - : tag.hasRelationshipWithItem(note); - return matchesTag && notePassesFilter( + return notePassesFilter( note, - this.appState.selectedTag!, this.getState().showArchived!, this.getState().hidePinned!, this.getState().noteFilter.text.toLowerCase() - ) + ); } - ) + ); } currentTagCanHavePlaceholderNotes() {