feat: ability to favorite tags (#1852)

This commit is contained in:
Mo
2022-10-20 09:28:35 -05:00
committed by GitHub
parent 9cc3304741
commit 4f3b258363
7 changed files with 81 additions and 27 deletions

View File

@@ -35,6 +35,7 @@ export class NavigationController
{
tags: SNTag[] = []
smartViews: SmartView[] = []
starredTags: SNTag[] = []
allNotesCount_ = 0
selectedUuid: AnyTag['uuid'] | undefined = undefined
selected_: AnyTag | undefined
@@ -66,6 +67,7 @@ export class NavigationController
makeObservable(this, {
tags: observable,
starredTags: observable,
smartViews: observable.ref,
hasAtLeastOneFolder: computed,
allNotesCount_: observable,
@@ -111,7 +113,7 @@ export class NavigationController
this.application.streamItems([ContentType.Tag, ContentType.SmartView], ({ changed, removed }) => {
runInAction(() => {
this.tags = this.application.items.getDisplayableTags()
this.starredTags = this.tags.filter((tag) => tag.starred)
this.smartViews = this.application.items.getSmartViews()
const currentSelectedTag = this.selected_
@@ -476,6 +478,14 @@ export class NavigationController
.catch(console.error)
}
public async setFavorite(tag: SNTag, favorite: boolean) {
return this.application.mutator
.changeAndSaveItem<TagMutator>(tag, (mutator) => {
mutator.starred = favorite
})
.catch(console.error)
}
public get editingTag(): SNTag | SmartView | undefined {
return this.editing_
}