chore: show invite count bubble on preferences button (#2458)

This commit is contained in:
Aman Harwara
2023-09-01 22:31:35 +05:30
committed by GitHub
parent 4ca291291c
commit be3b904f62
20 changed files with 158 additions and 54 deletions

View File

@@ -1,10 +1,44 @@
import { removeFromArray } from '@standardnotes/utils'
import { AbstractService } from '../Service/AbstractService'
import { StatusServiceEvent, StatusServiceInterface, StatusMessageIdentifier } from './StatusServiceInterface'
import { PreferencePaneId } from '../Preferences/PreferenceId'
/* istanbul ignore file */
export class StatusService extends AbstractService<StatusServiceEvent, string> implements StatusServiceInterface {
private preferencesBubbleCounts: Record<PreferencePaneId, number> = {
general: 0,
account: 0,
security: 0,
'home-server': 0,
vaults: 0,
appearance: 0,
backups: 0,
listed: 0,
shortcuts: 0,
accessibility: 0,
'get-free-month': 0,
'help-feedback': 0,
'whats-new': 0,
}
getPreferencesBubbleCount(preferencePaneId: PreferencePaneId): number {
return this.preferencesBubbleCounts[preferencePaneId]
}
setPreferencesBubbleCount(preferencePaneId: PreferencePaneId, count: number): void {
this.preferencesBubbleCounts[preferencePaneId] = count
const totalCount = this.totalPreferencesBubbleCount
void this.notifyEvent(
StatusServiceEvent.PreferencesBubbleCountChanged,
totalCount > 0 ? totalCount.toString() : undefined,
)
}
get totalPreferencesBubbleCount(): number {
return Object.values(this.preferencesBubbleCounts).reduce((total, count) => total + count, 0)
}
private _message = ''
private directSetMessage?: string
private dynamicMessages: string[] = []