Skip to content

Commit

Permalink
fix: do not display single note tags when viewing said tag
Browse files Browse the repository at this point in the history
  • Loading branch information
arielsvg committed Oct 26, 2020
1 parent d1e0101 commit 5cd7aa9
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions app/assets/javascripts/views/notes/notes_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,15 +355,12 @@ class NotesViewCtrl extends PureViewCtrl<{}, NotesState> {
if (!tag) {
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 renderedNotesTags = this.state.hideTags
? []
: renderedNotes.map((note) =>
this.appState.getNoteTags(note)
.map(tag => "#" + tag.title)
.join(" ")
);
const renderedNotesTags = this.notesTagsList(renderedNotes);

await this.setNotesState({
notes,
renderedNotesTags,
Expand All @@ -372,6 +369,33 @@ class NotesViewCtrl extends PureViewCtrl<{}, NotesState> {
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() {
this.setNotesState({
mutable: {
Expand Down

0 comments on commit 5cd7aa9

Please sign in to comment.