1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-22 16:29:09 +01:00

Merge pull request #1630 from vrnvorona/add-disable-badge-counter

Option to disable badge text on icon
This commit is contained in:
Chad Scharf 2021-03-12 15:23:56 -05:00 committed by GitHub
commit 23a56d5da2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 9 deletions

View File

@ -945,6 +945,12 @@
"disableFaviconDesc": { "disableFaviconDesc": {
"message": "Website Icons provide a recognizable image next to each login item in your vault." "message": "Website Icons provide a recognizable image next to each login item in your vault."
}, },
"disableBadgeCounter": {
"message": "Disable Badge Counter"
},
"disableBadgeCounterDesc": {
"message": "Badge counter indicates how many logins you have for the current page in your vault."
},
"cardholderName": { "cardholderName": {
"message": "Cardholder Name" "message": "Cardholder Name"
}, },

View File

@ -532,19 +532,24 @@ export default class MainBackground {
}); });
} }
const disableBadgeCounter = await this.storageService.get<boolean>(ConstantsService.disableBadgeCounterKey);
let theText = ''; let theText = '';
if (ciphers.length > 0 && ciphers.length <= 9) {
theText = ciphers.length.toString(); if (!disableBadgeCounter) {
} else if (ciphers.length > 0) { if (ciphers.length > 0 && ciphers.length <= 9) {
theText = '9+'; theText = ciphers.length.toString();
} else { } else if (ciphers.length > 0) {
if (contextMenuEnabled) { theText = '9+';
await this.loadNoLoginsContextMenuOptions(this.i18nService.t('noMatchingLogins'));
} }
} }
this.browserActionSetBadgeText(theText, tabId); if (contextMenuEnabled && ciphers.length === 0) {
await this.loadNoLoginsContextMenuOptions(this.i18nService.t('noMatchingLogins'));
}
this.sidebarActionSetBadgeText(theText, tabId); this.sidebarActionSetBadgeText(theText, tabId);
this.browserActionSetBadgeText(theText, tabId);
return; return;
} catch { } } catch { }
} }

View File

@ -90,9 +90,12 @@ export function initFactory(platformUtilsService: PlatformUtilsService, i18nServ
} }
if (BrowserApi.getBackgroundPage() != null) { if (BrowserApi.getBackgroundPage() != null) {
stateService.save(ConstantsService.disableFaviconKey, await stateService.save(ConstantsService.disableFaviconKey,
await storageService.get<boolean>(ConstantsService.disableFaviconKey)); await storageService.get<boolean>(ConstantsService.disableFaviconKey));
await stateService.save(ConstantsService.disableBadgeCounterKey,
await storageService.get<boolean>(ConstantsService.disableBadgeCounterKey));
let theme = await storageService.get<string>(ConstantsService.themeKey); let theme = await storageService.get<string>(ConstantsService.themeKey);
if (theme == null) { if (theme == null) {
theme = platformUtilsService.getDefaultSystemTheme(); theme = platformUtilsService.getDefaultSystemTheme();

View File

@ -115,6 +115,15 @@
</div> </div>
<div class="box-footer">{{'disableFaviconDesc' | i18n}}</div> <div class="box-footer">{{'disableFaviconDesc' | i18n}}</div>
</div> </div>
<div class="box">
<div class="box-content">
<div class="box-content-row box-content-row-checkbox" appBoxRow>
<label for="badge">{{'disableBadgeCounter' | i18n}}</label>
<input id="badge" type="checkbox" (change)="updateDisableBadgeCounter()" [(ngModel)]="disableBadgeCounter">
</div>
</div>
<div class="box-footer">{{'disableBadgeCounterDesc' | i18n}}</div>
</div>
<div class="box"> <div class="box">
<div class="box-content"> <div class="box-content">
<div class="box-content-row" appBoxRow> <div class="box-content-row" appBoxRow>

View File

@ -22,6 +22,7 @@ import { ConstantsService } from 'jslib/services/constants.service';
}) })
export class OptionsComponent implements OnInit { export class OptionsComponent implements OnInit {
disableFavicon = false; disableFavicon = false;
disableBadgeCounter = false;
enableAutoFillOnPageLoad = false; enableAutoFillOnPageLoad = false;
disableAutoTotpCopy = false; disableAutoTotpCopy = false;
disableContextMenuItem = false; disableContextMenuItem = false;
@ -86,6 +87,8 @@ export class OptionsComponent implements OnInit {
this.disableFavicon = await this.storageService.get<boolean>(ConstantsService.disableFaviconKey); this.disableFavicon = await this.storageService.get<boolean>(ConstantsService.disableFaviconKey);
this.disableBadgeCounter = await this.storageService.get<boolean>(ConstantsService.disableBadgeCounterKey);
this.theme = await this.storageService.get<string>(ConstantsService.themeKey); this.theme = await this.storageService.get<string>(ConstantsService.themeKey);
const defaultUriMatch = await this.storageService.get<UriMatchType>(ConstantsService.defaultUriMatch); const defaultUriMatch = await this.storageService.get<UriMatchType>(ConstantsService.defaultUriMatch);
@ -129,6 +132,12 @@ export class OptionsComponent implements OnInit {
this.callAnalytics('Favicon', !this.disableFavicon); this.callAnalytics('Favicon', !this.disableFavicon);
} }
async updateDisableBadgeCounter() {
await this.storageService.save(ConstantsService.disableBadgeCounterKey, this.disableBadgeCounter);
await this.stateService.save(ConstantsService.disableBadgeCounterKey, this.disableBadgeCounter);
this.messagingService.send('bgUpdateContextMenu');
}
async updateShowCards() { async updateShowCards() {
await this.storageService.save(ConstantsService.dontShowCardsCurrentTab, this.dontShowCards); await this.storageService.save(ConstantsService.dontShowCardsCurrentTab, this.dontShowCards);
await this.stateService.save(ConstantsService.dontShowCardsCurrentTab, this.dontShowCards); await this.stateService.save(ConstantsService.dontShowCardsCurrentTab, this.dontShowCards);