chore: update preference menu bubble counts correctly
This commit is contained in:
@@ -2,7 +2,7 @@ import { action, makeAutoObservable, observable } from 'mobx'
|
|||||||
import { WebApplication } from '@/Application/WebApplication'
|
import { WebApplication } from '@/Application/WebApplication'
|
||||||
import { PackageProvider } from '../Panes/General/Advanced/Packages/Provider/PackageProvider'
|
import { PackageProvider } from '../Panes/General/Advanced/Packages/Provider/PackageProvider'
|
||||||
import { securityPrefsHasBubble } from '../Panes/Security/securityPrefsHasBubble'
|
import { securityPrefsHasBubble } from '../Panes/Security/securityPrefsHasBubble'
|
||||||
import { PreferencePaneId } from '@standardnotes/services'
|
import { PreferencePaneId, StatusServiceEvent } from '@standardnotes/services'
|
||||||
import { isDesktopApplication } from '@/Utils'
|
import { isDesktopApplication } from '@/Utils'
|
||||||
import { featureTrunkHomeServerEnabled, featureTrunkVaultsEnabled } from '@/FeatureTrunk'
|
import { featureTrunkHomeServerEnabled, featureTrunkVaultsEnabled } from '@/FeatureTrunk'
|
||||||
import { PreferencesMenuItem } from './PreferencesMenuItem'
|
import { PreferencesMenuItem } from './PreferencesMenuItem'
|
||||||
@@ -40,13 +40,34 @@ export class PreferencesSessionController {
|
|||||||
|
|
||||||
makeAutoObservable<
|
makeAutoObservable<
|
||||||
PreferencesSessionController,
|
PreferencesSessionController,
|
||||||
'_selectedPane' | '_twoFactorAuth' | '_extensionPanes' | '_extensionLatestVersions' | 'loadLatestVersions'
|
| '_selectedPane'
|
||||||
|
| '_twoFactorAuth'
|
||||||
|
| '_extensionPanes'
|
||||||
|
| '_extensionLatestVersions'
|
||||||
|
| 'loadLatestVersions'
|
||||||
|
| 'updateMenuBubbleCounts'
|
||||||
>(this, {
|
>(this, {
|
||||||
_twoFactorAuth: observable,
|
_twoFactorAuth: observable,
|
||||||
_selectedPane: observable,
|
_selectedPane: observable,
|
||||||
_extensionPanes: observable.ref,
|
_extensionPanes: observable.ref,
|
||||||
_extensionLatestVersions: observable.ref,
|
_extensionLatestVersions: observable.ref,
|
||||||
loadLatestVersions: action,
|
loadLatestVersions: action,
|
||||||
|
updateMenuBubbleCounts: action,
|
||||||
|
})
|
||||||
|
|
||||||
|
this.application.status.addEventObserver((event) => {
|
||||||
|
if (event === StatusServiceEvent.PreferencesBubbleCountChanged) {
|
||||||
|
this.updateMenuBubbleCounts()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private updateMenuBubbleCounts(): void {
|
||||||
|
this._menu = this._menu.map((item) => {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
bubbleCount: this.application.status.getPreferencesBubbleCount(item.id),
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +90,6 @@ export class PreferencesSessionController {
|
|||||||
const item: SelectableMenuItem = {
|
const item: SelectableMenuItem = {
|
||||||
...preference,
|
...preference,
|
||||||
selected: preference.id === this._selectedPane,
|
selected: preference.id === this._selectedPane,
|
||||||
bubbleCount: this.application.status.getPreferencesBubbleCount(preference.id),
|
|
||||||
hasErrorIndicator: this.sectionHasBubble(preference.id),
|
hasErrorIndicator: this.sectionHasBubble(preference.id),
|
||||||
}
|
}
|
||||||
return item
|
return item
|
||||||
|
|||||||
Reference in New Issue
Block a user