fix: restore showing tags in the notes view

This commit is contained in:
Baptiste Grob
2020-10-23 11:17:17 +02:00
parent 27affa4cee
commit 54ed0bdabb
4 changed files with 31 additions and 5 deletions

View File

@@ -94,6 +94,13 @@
faded="self.state.hideDate" faded="self.state.hideDate"
label="'Date'" label="'Date'"
) )
menu-row(
action="self.selectedMenuItem(); self.toggleWebPrefKey('hideTags')"
circle="self.state.hideTags ? 'danger' : 'success'"
desc="'Hide the list of tags associated with each note'"
faded="self.state.hideTags"
label="'Tags'"
)
p.empty-notes-list.faded( p.empty-notes-list.faded(
ng-if="self.state.completedFullSync && !self.state.renderedNotes.length" ng-if="self.state.completedFullSync && !self.state.renderedNotes.length"
) No notes. ) No notes.
@@ -137,6 +144,8 @@
| Modified {{note.updatedAtString || 'Now'}} | Modified {{note.updatedAtString || 'Now'}}
span(ng-show="self.state.sortBy != 'userModifiedDate'") span(ng-show="self.state.sortBy != 'userModifiedDate'")
| {{note.createdAtString || 'Now'}} | {{note.createdAtString || 'Now'}}
.tags-string(ng-if='!self.state.hideTags && self.state.renderedNotesTags[$index]')
.faded {{self.state.renderedNotesTags[$index]}}
panel-resizer( panel-resizer(
collapsable="true" collapsable="true"

View File

@@ -26,12 +26,14 @@ type NotesState = {
panelTitle: string panelTitle: string
notes?: SNNote[] notes?: SNNote[]
renderedNotes: SNNote[] renderedNotes: SNNote[]
renderedNotesTags: string[],
sortBy?: string sortBy?: string
sortReverse?: boolean sortReverse?: boolean
showArchived?: boolean showArchived?: boolean
hidePinned?: boolean hidePinned?: boolean
hideNotePreview?: boolean hideNotePreview?: boolean
hideDate?: boolean hideDate?: boolean
hideTags: boolean
noteFilter: { text: string } noteFilter: { text: string }
mutable: { showMenu: boolean } mutable: { showMenu: boolean }
completedFullSync: boolean completedFullSync: boolean
@@ -124,10 +126,12 @@ class NotesViewCtrl extends PureViewCtrl<{}, NotesState> {
return { return {
notes: [], notes: [],
renderedNotes: [], renderedNotes: [],
renderedNotesTags: [],
mutable: { showMenu: false }, mutable: { showMenu: false },
noteFilter: { text: '' }, noteFilter: { text: '' },
panelTitle: '', panelTitle: '',
completedFullSync: false, completedFullSync: false,
hideTags: true,
}; };
} }
@@ -352,9 +356,17 @@ class NotesViewCtrl extends PureViewCtrl<{}, NotesState> {
return; return;
} }
const notes = this.application.getDisplayableItems(ContentType.Note) as SNNote[]; const notes = this.application.getDisplayableItems(ContentType.Note) as SNNote[];
let renderedNotes = notes.slice(0, this.notesToDisplay); const renderedNotes = notes.slice(0, this.notesToDisplay);
const renderedNotesTags = this.state.hideTags
? []
: renderedNotes.map((note) =>
this.appState.getNoteTags(note)
.map(tag => "#" + tag.title)
.join(" ")
);
await this.setNotesState({ await this.setNotesState({
notes, notes,
renderedNotesTags,
renderedNotes, renderedNotes,
}); });
this.reloadPanelTitle(); this.reloadPanelTitle();
@@ -413,12 +425,17 @@ class NotesViewCtrl extends PureViewCtrl<{}, NotesState> {
WebPrefKey.NotesHideDate, WebPrefKey.NotesHideDate,
false false
); );
viewOptions.hideTags = this.application.getPrefsService().getValue(
WebPrefKey.NotesHideTags,
true,
);
const state = this.getState(); const state = this.getState();
const displayOptionsChanged = ( const displayOptionsChanged = (
viewOptions.sortBy !== state.sortBy || viewOptions.sortBy !== state.sortBy ||
viewOptions.sortReverse !== state.sortReverse || viewOptions.sortReverse !== state.sortReverse ||
viewOptions.hidePinned !== state.hidePinned || viewOptions.hidePinned !== state.hidePinned ||
viewOptions.showArchived !== state.showArchived viewOptions.showArchived !== state.showArchived ||
viewOptions.hideTags !== state.hideTags
); );
await this.setNotesState({ await this.setNotesState({
...viewOptions ...viewOptions

4
package-lock.json generated
View File

@@ -10961,8 +10961,8 @@
"from": "github:standardnotes/sncrypto#8794c88daa967eaae493cd5fdec7506d52b257ad" "from": "github:standardnotes/sncrypto#8794c88daa967eaae493cd5fdec7506d52b257ad"
}, },
"snjs": { "snjs": {
"version": "github:standardnotes/snjs#8aafecd58a2ec889414cf21c0425b8df4ae43538", "version": "github:standardnotes/snjs#c0ebfffae2c6c380b62aa080bac073a886e0d0a8",
"from": "github:standardnotes/snjs#8aafecd58a2ec889414cf21c0425b8df4ae43538" "from": "github:standardnotes/snjs#c0ebfffae2c6c380b62aa080bac073a886e0d0a8"
}, },
"sockjs": { "sockjs": {
"version": "0.3.20", "version": "0.3.20",

View File

@@ -71,6 +71,6 @@
"dependencies": { "dependencies": {
"mobx": "^6.0.1", "mobx": "^6.0.1",
"sncrypto": "github:standardnotes/sncrypto#8794c88daa967eaae493cd5fdec7506d52b257ad", "sncrypto": "github:standardnotes/sncrypto#8794c88daa967eaae493cd5fdec7506d52b257ad",
"snjs": "github:standardnotes/snjs#8aafecd58a2ec889414cf21c0425b8df4ae43538" "snjs": "github:standardnotes/snjs#c0ebfffae2c6c380b62aa080bac073a886e0d0a8"
} }
} }