fix: do not display single note tags when viewing said tag
This commit is contained in:
@@ -355,15 +355,12 @@ class NotesViewCtrl extends PureViewCtrl<{}, NotesState> {
|
|||||||
if (!tag) {
|
if (!tag) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const notes = this.application.getDisplayableItems(ContentType.Note) as SNNote[];
|
const notes = this.application.getDisplayableItems(
|
||||||
|
ContentType.Note
|
||||||
|
) as SNNote[];
|
||||||
const renderedNotes = notes.slice(0, this.notesToDisplay);
|
const renderedNotes = notes.slice(0, this.notesToDisplay);
|
||||||
const renderedNotesTags = this.state.hideTags
|
const renderedNotesTags = this.notesTagsList(renderedNotes);
|
||||||
? []
|
|
||||||
: renderedNotes.map((note) =>
|
|
||||||
this.appState.getNoteTags(note)
|
|
||||||
.map(tag => "#" + tag.title)
|
|
||||||
.join(" ")
|
|
||||||
);
|
|
||||||
await this.setNotesState({
|
await this.setNotesState({
|
||||||
notes,
|
notes,
|
||||||
renderedNotesTags,
|
renderedNotesTags,
|
||||||
@@ -372,6 +369,33 @@ class NotesViewCtrl extends PureViewCtrl<{}, NotesState> {
|
|||||||
this.reloadPanelTitle();
|
this.reloadPanelTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private notesTagsList(notes: SNNote[]): string[] {
|
||||||
|
if (this.state.hideTags) {
|
||||||
|
return [];
|
||||||
|
} else {
|
||||||
|
const selectedTag = this.appState.selectedTag;
|
||||||
|
if (!selectedTag) {
|
||||||
|
return [];
|
||||||
|
} else if (selectedTag?.isSmartTag()) {
|
||||||
|
return notes.map((note) =>
|
||||||
|
this.appState
|
||||||
|
.getNoteTags(note)
|
||||||
|
.map((tag) => '#' + tag.title)
|
||||||
|
.join(' ')
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
/**
|
||||||
|
* Displaying a normal tag, hide the note's tag when there's only one
|
||||||
|
*/
|
||||||
|
return notes.map((note) => {
|
||||||
|
const tags = this.appState.getNoteTags(note);
|
||||||
|
if (tags.length === 1) return '';
|
||||||
|
return tags.map((tag) => '#' + tag.title).join(' ');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setShowMenuFalse() {
|
setShowMenuFalse() {
|
||||||
this.setNotesState({
|
this.setNotesState({
|
||||||
mutable: {
|
mutable: {
|
||||||
|
|||||||
Reference in New Issue
Block a user