From 6d2829a200ef32fa22dc521f39d6a905b7b848ab Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 5 Jan 2022 09:19:31 +0100 Subject: [PATCH] fix: reload note counts --- .../components/Tags/SmartTagsSection.tsx | 1 - .../ui_models/app_state/tags_state.ts | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/components/Tags/SmartTagsSection.tsx b/app/assets/javascripts/components/Tags/SmartTagsSection.tsx index d647ca6ef93..2032aa6cee3 100644 --- a/app/assets/javascripts/components/Tags/SmartTagsSection.tsx +++ b/app/assets/javascripts/components/Tags/SmartTagsSection.tsx @@ -1,4 +1,3 @@ -import { WebApplication } from '@/ui_models/application'; import { AppState } from '@/ui_models/app_state'; import { observer } from 'mobx-react-lite'; import { FunctionComponent } from 'preact'; diff --git a/app/assets/javascripts/ui_models/app_state/tags_state.ts b/app/assets/javascripts/ui_models/app_state/tags_state.ts index 905bcfa80c8..ea2c6201512 100644 --- a/app/assets/javascripts/ui_models/app_state/tags_state.ts +++ b/app/assets/javascripts/ui_models/app_state/tags_state.ts @@ -1,6 +1,7 @@ import { confirmDialog } from '@/services/alertService'; import { STRING_DELETE_TAG, STRING_MISSING_SYSTEM_TAG } from '@/strings'; import { + ApplicationEvent, ComponentAction, ContentType, MessageData, @@ -8,7 +9,7 @@ import { SNSmartTag, SNTag, TagMutator, - UuidString + UuidString, } from '@standardnotes/snjs'; import { action, @@ -16,7 +17,7 @@ import { makeAutoObservable, makeObservable, observable, - runInAction + runInAction, } from 'mobx'; import { WebApplication } from '../application'; import { FeaturesState, SMART_TAGS_FEATURE_NAME } from './features_state'; @@ -146,6 +147,18 @@ export class TagsState { } ) ); + + appEventListeners.push( + this.application.addEventObserver(async (eventName) => { + switch (eventName) { + case ApplicationEvent.CompletedIncrementalSync: + runInAction(() => { + this.allNotesCount_ = this.countAllNotes(); + }); + break; + } + }) + ); } public get allLocalRootTags(): SNTag[] {