refactor: move setting allNotesCount_ into action (#877)
This commit is contained in:
@@ -95,6 +95,7 @@ export class TagsState {
|
|||||||
hasAtLeastOneFolder: computed,
|
hasAtLeastOneFolder: computed,
|
||||||
allNotesCount_: observable,
|
allNotesCount_: observable,
|
||||||
allNotesCount: computed,
|
allNotesCount: computed,
|
||||||
|
setAllNotesCount: action,
|
||||||
|
|
||||||
selected_: observable.ref,
|
selected_: observable.ref,
|
||||||
previouslySelected_: observable.ref,
|
previouslySelected_: observable.ref,
|
||||||
@@ -148,9 +149,7 @@ export class TagsState {
|
|||||||
appEventListeners.push(
|
appEventListeners.push(
|
||||||
this.application.addNoteCountChangeObserver((tagUuid) => {
|
this.application.addNoteCountChangeObserver((tagUuid) => {
|
||||||
if (!tagUuid) {
|
if (!tagUuid) {
|
||||||
runInAction(() => {
|
this.setAllNotesCount(this.application.allCountableNotesCount());
|
||||||
this.allNotesCount_ = this.application.allCountableNotesCount();
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
this.tagsCountsState.update([
|
this.tagsCountsState.update([
|
||||||
this.application.findItem(tagUuid) as SNTag,
|
this.application.findItem(tagUuid) as SNTag,
|
||||||
@@ -238,6 +237,10 @@ export class TagsState {
|
|||||||
return this.tags.length;
|
return this.tags.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setAllNotesCount(allNotesCount: number) {
|
||||||
|
this.allNotesCount_ = allNotesCount;
|
||||||
|
}
|
||||||
|
|
||||||
public get allNotesCount(): number {
|
public get allNotesCount(): number {
|
||||||
return this.allNotesCount_;
|
return this.allNotesCount_;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user