refactor: move setting allNotesCount_ into action (#877)

This commit is contained in:
Aman Harwara
2022-02-17 02:21:37 +05:30
committed by GitHub
parent ca3112dcaf
commit 1717fbf545

View File

@@ -95,6 +95,7 @@ export class TagsState {
hasAtLeastOneFolder: computed,
allNotesCount_: observable,
allNotesCount: computed,
setAllNotesCount: action,
selected_: observable.ref,
previouslySelected_: observable.ref,
@@ -148,9 +149,7 @@ export class TagsState {
appEventListeners.push(
this.application.addNoteCountChangeObserver((tagUuid) => {
if (!tagUuid) {
runInAction(() => {
this.allNotesCount_ = this.application.allCountableNotesCount();
});
this.setAllNotesCount(this.application.allCountableNotesCount());
} else {
this.tagsCountsState.update([
this.application.findItem(tagUuid) as SNTag,
@@ -238,6 +237,10 @@ export class TagsState {
return this.tags.length;
}
setAllNotesCount(allNotesCount: number) {
this.allNotesCount_ = allNotesCount;
}
public get allNotesCount(): number {
return this.allNotesCount_;
}