fix: smart tags
This commit is contained in:
@@ -851,7 +851,7 @@ class EditorViewCtrl extends PureViewCtrl<{}, EditorState> {
|
|||||||
for (const tag of removeTags) {
|
for (const tag of removeTags) {
|
||||||
await this.application.changeItem(tag.uuid, (mutator) => {
|
await this.application.changeItem(tag.uuid, (mutator) => {
|
||||||
mutator.removeItemAsRelationship(note);
|
mutator.removeItemAsRelationship(note);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
const newRelationships: SNTag[] = [];
|
const newRelationships: SNTag[] = [];
|
||||||
for (const title of strings) {
|
for (const title of strings) {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ export enum NoteSortKey {
|
|||||||
|
|
||||||
export function notePassesFilter(
|
export function notePassesFilter(
|
||||||
note: SNNote,
|
note: SNNote,
|
||||||
selectedTag: SNTag,
|
|
||||||
showArchived: boolean,
|
showArchived: boolean,
|
||||||
hidePinned: boolean,
|
hidePinned: boolean,
|
||||||
filterText: string
|
filterText: string
|
||||||
@@ -21,17 +20,6 @@ export function notePassesFilter(
|
|||||||
|
|
||||||
let canShowArchived = showArchived;
|
let canShowArchived = showArchived;
|
||||||
const canShowPinned = !hidePinned;
|
const canShowPinned = !hidePinned;
|
||||||
if (!selectedTag.isTrashTag && note.trashed) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const isSmartTag = selectedTag.isSmartTag();
|
|
||||||
if (isSmartTag) {
|
|
||||||
canShowArchived = (
|
|
||||||
canShowArchived ||
|
|
||||||
selectedTag.isArchiveTag ||
|
|
||||||
selectedTag.isTrashTag
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (
|
if (
|
||||||
(note.archived && !canShowArchived) ||
|
(note.archived && !canShowArchived) ||
|
||||||
(note.pinned && !canShowPinned)
|
(note.pinned && !canShowPinned)
|
||||||
@@ -79,4 +67,4 @@ function stringIsUuid(text: string) {
|
|||||||
);
|
);
|
||||||
// eslint-disable-next-line no-unneeded-ternary
|
// eslint-disable-next-line no-unneeded-ternary
|
||||||
return matches ? true : false;
|
return matches ? true : false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import {
|
|||||||
WebPrefKey,
|
WebPrefKey,
|
||||||
findInArray,
|
findInArray,
|
||||||
CollectionSort,
|
CollectionSort,
|
||||||
SNSmartTag
|
|
||||||
} from 'snjs';
|
} from 'snjs';
|
||||||
import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl';
|
import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl';
|
||||||
import { AppStateEvent } from '@/ui_models/app_state';
|
import { AppStateEvent } from '@/ui_models/app_state';
|
||||||
@@ -331,23 +330,19 @@ class NotesViewCtrl extends PureViewCtrl<{}, NotesState> {
|
|||||||
*/
|
*/
|
||||||
private reloadNotesDisplayOptions() {
|
private reloadNotesDisplayOptions() {
|
||||||
const tag = this.appState.selectedTag!;
|
const tag = this.appState.selectedTag!;
|
||||||
this.application.setDisplayOptions(
|
this.application!.setNotesDisplayOptions(
|
||||||
ContentType.Note,
|
tag,
|
||||||
this.getState().sortBy! as CollectionSort,
|
this.state.sortBy! as CollectionSort,
|
||||||
this.getState().sortReverse! ? 'asc' : 'dsc',
|
this.state.sortReverse! ? 'asc' : 'dsc',
|
||||||
(note: SNNote) => {
|
(note: SNNote) => {
|
||||||
const matchesTag = tag.isSmartTag()
|
return notePassesFilter(
|
||||||
? note.satisfiesPredicate((tag as SNSmartTag).predicate)
|
|
||||||
: tag.hasRelationshipWithItem(note);
|
|
||||||
return matchesTag && notePassesFilter(
|
|
||||||
note,
|
note,
|
||||||
this.appState.selectedTag!,
|
|
||||||
this.getState().showArchived!,
|
this.getState().showArchived!,
|
||||||
this.getState().hidePinned!,
|
this.getState().hidePinned!,
|
||||||
this.getState().noteFilter.text.toLowerCase()
|
this.getState().noteFilter.text.toLowerCase()
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentTagCanHavePlaceholderNotes() {
|
currentTagCanHavePlaceholderNotes() {
|
||||||
|
|||||||
Reference in New Issue
Block a user