From 518722c7815a9389b33a0e644ca01683c178d262 Mon Sep 17 00:00:00 2001 From: Vlad Date: Sat, 6 Mar 2021 19:18:11 +0300 Subject: [PATCH] Fixes for text logic Moved settings check above setting text, also added send message when settings is changed Now when settings is changed, current tab badge is changed immediately, and other tabs do so in milliseconds after switch --- src/background/main.background.ts | 25 +++++++++++++------------ src/popup/settings/options.component.ts | 1 + 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/background/main.background.ts b/src/background/main.background.ts index 8ffb32123f1..492a07be6b0 100644 --- a/src/background/main.background.ts +++ b/src/background/main.background.ts @@ -532,22 +532,23 @@ export default class MainBackground { }); } + const disableBadgeCounter = await this.storageService.get(ConstantsService.disableBadgeCounterKey); let theText = ''; - if (ciphers.length > 0 && ciphers.length <= 9) { - theText = ciphers.length.toString(); - } else if (ciphers.length > 0) { - theText = '9+'; - } else { - if (contextMenuEnabled) { - await this.loadNoLoginsContextMenuOptions(this.i18nService.t('noMatchingLogins')); + + if (!disableBadgeCounter) { + if (ciphers.length > 0 && ciphers.length <= 9) { + theText = ciphers.length.toString(); + } else if (ciphers.length > 0) { + theText = '9+'; + } else { + if (contextMenuEnabled) { + await this.loadNoLoginsContextMenuOptions(this.i18nService.t('noMatchingLogins')); + } } } - const disableBadgeCounter = await this.storageService.get(ConstantsService.disableBadgeCounterKey); - if (!disableBadgeCounter) { - this.sidebarActionSetBadgeText(theText, tabId); - this.browserActionSetBadgeText(theText, tabId); - } + this.sidebarActionSetBadgeText(theText, tabId); + this.browserActionSetBadgeText(theText, tabId); return; } catch { } diff --git a/src/popup/settings/options.component.ts b/src/popup/settings/options.component.ts index d850e094f22..dc2bea76bab 100644 --- a/src/popup/settings/options.component.ts +++ b/src/popup/settings/options.component.ts @@ -135,6 +135,7 @@ export class OptionsComponent implements OnInit { async updateDisableBadgeCounter() { await this.storageService.save(ConstantsService.disableBadgeCounterKey, this.disableBadgeCounter); await this.stateService.save(ConstantsService.disableBadgeCounterKey, this.disableBadgeCounter); + this.messagingService.send('bgUpdateContextMenu'); } async updateShowCards() {