diff --git a/apps/browser/src/autofill/popup/settings/autofill.component.ts b/apps/browser/src/autofill/popup/settings/autofill.component.ts index 728b74bc90..17accea674 100644 --- a/apps/browser/src/autofill/popup/settings/autofill.component.ts +++ b/apps/browser/src/autofill/popup/settings/autofill.component.ts @@ -9,7 +9,7 @@ import { StateService } from "@bitwarden/common/platform/abstractions/state.serv import { UriMatchType } from "@bitwarden/common/vault/enums"; import { BrowserApi } from "../../../platform/browser/browser-api"; -import { flagEnabled } from "../../../platform/flags"; +import { enableAccountSwitching } from "../../../platform/flags"; import { AutofillService } from "../../services/abstractions/autofill.service"; import { AutofillOverlayVisibility } from "../../utils/autofill-overlay.enum"; @@ -65,7 +65,7 @@ export class AutofillComponent implements OnInit { { name: i18nService.t("never"), value: UriMatchType.Never }, ]; - this.accountSwitcherEnabled = flagEnabled("accountSwitching"); + this.accountSwitcherEnabled = enableAccountSwitching(); this.disablePasswordManagerLink = this.getDisablePasswordManagerLink(); } diff --git a/apps/browser/src/platform/flags.ts b/apps/browser/src/platform/flags.ts index f5c17ea7b4..71a20edc5e 100644 --- a/apps/browser/src/platform/flags.ts +++ b/apps/browser/src/platform/flags.ts @@ -8,6 +8,8 @@ import { import { GroupPolicyEnvironment } from "../admin-console/types/group-policy-environment"; +import { BrowserApi } from "./browser/browser-api"; + // required to avoid linting errors when there are no flags /* eslint-disable-next-line @typescript-eslint/ban-types */ export type Flags = { @@ -32,3 +34,14 @@ export function devFlagEnabled(flag: keyof DevFlags) { export function devFlagValue(flag: keyof DevFlags) { return baseDevFlagValue(flag); } + +/** Helper method to sync flag specifically for account switching, which as platform-based values. + * If this pattern needs to be repeated, it's better handled by increasing complexity of webpack configurations + * Not by expanding these flag getters. + */ +export function enableAccountSwitching(): boolean { + if (BrowserApi.isSafariApi) { + return false; + } + return flagEnabled("accountSwitching"); +} diff --git a/apps/browser/src/platform/popup/header.component.ts b/apps/browser/src/platform/popup/header.component.ts index 4ae25f8b28..6b9e9c9a3e 100644 --- a/apps/browser/src/platform/popup/header.component.ts +++ b/apps/browser/src/platform/popup/header.component.ts @@ -4,7 +4,7 @@ import { Observable, map } from "rxjs"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; -import { flagEnabled } from "../flags"; +import { enableAccountSwitching } from "../flags"; @Component({ selector: "app-header", @@ -17,7 +17,7 @@ export class HeaderComponent { constructor(accountService: AccountService) { this.authedAccounts$ = accountService.accounts$.pipe( map((accounts) => { - if (!flagEnabled("accountSwitching")) { + if (!enableAccountSwitching()) { return false; } diff --git a/apps/browser/src/popup/settings/excluded-domains.component.ts b/apps/browser/src/popup/settings/excluded-domains.component.ts index 85a7ba0643..cb1810521f 100644 --- a/apps/browser/src/popup/settings/excluded-domains.component.ts +++ b/apps/browser/src/popup/settings/excluded-domains.component.ts @@ -8,7 +8,7 @@ import { StateService } from "@bitwarden/common/platform/abstractions/state.serv import { Utils } from "@bitwarden/common/platform/misc/utils"; import { BrowserApi } from "../../platform/browser/browser-api"; -import { flagEnabled } from "../../platform/flags"; +import { enableAccountSwitching } from "../../platform/flags"; interface ExcludedDomain { uri: string; @@ -36,7 +36,7 @@ export class ExcludedDomainsComponent implements OnInit, OnDestroy { private ngZone: NgZone, private platformUtilsService: PlatformUtilsService, ) { - this.accountSwitcherEnabled = flagEnabled("accountSwitching"); + this.accountSwitcherEnabled = enableAccountSwitching(); } async ngOnInit() { diff --git a/apps/browser/src/popup/settings/options.component.ts b/apps/browser/src/popup/settings/options.component.ts index cac8540529..eb8025b431 100644 --- a/apps/browser/src/popup/settings/options.component.ts +++ b/apps/browser/src/popup/settings/options.component.ts @@ -9,7 +9,7 @@ import { ThemeType } from "@bitwarden/common/platform/enums"; import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service"; import { UriMatchType } from "@bitwarden/common/vault/enums"; -import { flagEnabled } from "../../platform/flags"; +import { enableAccountSwitching } from "../../platform/flags"; @Component({ selector: "app-options", @@ -77,7 +77,7 @@ export class OptionsComponent implements OnInit { { name: i18nService.t("autoFillOnPageLoadNo"), value: false }, ]; - this.accountSwitcherEnabled = flagEnabled("accountSwitching"); + this.accountSwitcherEnabled = enableAccountSwitching(); } async ngOnInit() { diff --git a/apps/browser/src/popup/settings/settings.component.ts b/apps/browser/src/popup/settings/settings.component.ts index d1fee44a3e..64edb6ae42 100644 --- a/apps/browser/src/popup/settings/settings.component.ts +++ b/apps/browser/src/popup/settings/settings.component.ts @@ -36,7 +36,7 @@ import { DialogService } from "@bitwarden/components"; import { SetPinComponent } from "../../auth/popup/components/set-pin.component"; import { BiometricErrors, BiometricErrorTypes } from "../../models/biometricErrors"; import { BrowserApi } from "../../platform/browser/browser-api"; -import { flagEnabled } from "../../platform/flags"; +import { enableAccountSwitching } from "../../platform/flags"; import BrowserPopupUtils from "../../platform/popup/browser-popup-utils"; import { AboutComponent } from "./about.component"; @@ -102,7 +102,7 @@ export class SettingsComponent implements OnInit { private dialogService: DialogService, private changeDetectorRef: ChangeDetectorRef, ) { - this.accountSwitcherEnabled = flagEnabled("accountSwitching"); + this.accountSwitcherEnabled = enableAccountSwitching(); } async ngOnInit() {