1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 15:23:33 +00:00

[PM-18529] Remove persist-popup-view feature flag (#13519)

* Removed feature flag from clients

* Removed feature flag test
This commit is contained in:
Todd Martin
2025-02-24 12:34:15 -05:00
committed by GitHub
parent 030acc6421
commit bc7c22ae01
4 changed files with 9 additions and 51 deletions

View File

@@ -9,10 +9,8 @@ import {
Router,
UrlSerializer,
} from "@angular/router";
import { filter, first, firstValueFrom, map, Observable, of, switchMap, tap } from "rxjs";
import { filter, first, firstValueFrom, map, Observable, switchMap, tap } from "rxjs";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { GlobalStateProvider } from "@bitwarden/common/platform/state";
import { POPUP_ROUTE_HISTORY_KEY } from "../../../platform/services/popup-view-cache-background.service";
@@ -113,29 +111,18 @@ export class PopupRouterCacheService {
/**
* Redirect to the last visited route. Should be applied to root route.
*
* If `FeatureFlag.PersistPopupView` is disabled, do nothing.
**/
export const popupRouterCacheGuard = (() => {
const configService = inject(ConfigService);
const popupHistoryService = inject(PopupRouterCacheService);
const urlSerializer = inject(UrlSerializer);
return configService.getFeatureFlag$(FeatureFlag.PersistPopupView).pipe(
switchMap((featureEnabled) => {
if (!featureEnabled) {
return of(true);
return popupHistoryService.last$().pipe(
map((url: string) => {
if (!url) {
return true;
}
return popupHistoryService.last$().pipe(
map((url: string) => {
if (!url) {
return true;
}
return urlSerializer.parse(url);
}),
);
return urlSerializer.parse(url);
}),
);
}) satisfies CanActivateFn;

View File

@@ -20,8 +20,6 @@ import {
SignalCacheOptions,
ViewCacheService,
} from "@bitwarden/angular/platform/abstractions/view-cache.service";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { MessageSender } from "@bitwarden/common/platform/messaging";
import { GlobalStateProvider } from "@bitwarden/common/platform/state";
@@ -40,13 +38,10 @@ import {
providedIn: "root",
})
export class PopupViewCacheService implements ViewCacheService {
private configService = inject(ConfigService);
private globalStateProvider = inject(GlobalStateProvider);
private messageSender = inject(MessageSender);
private router = inject(Router);
private featureEnabled: boolean;
private _cache: Record<string, string>;
private get cache(): Record<string, string> {
if (!this._cache) {
@@ -59,10 +54,9 @@ export class PopupViewCacheService implements ViewCacheService {
* Initialize the service. This should only be called once.
*/
async init() {
this.featureEnabled = await this.configService.getFeatureFlag(FeatureFlag.PersistPopupView);
const initialState = this.featureEnabled
? await firstValueFrom(this.globalStateProvider.get(POPUP_VIEW_CACHE_KEY).state$)
: {};
const initialState = await firstValueFrom(
this.globalStateProvider.get(POPUP_VIEW_CACHE_KEY).state$,
);
this._cache = Object.freeze(initialState ?? {});
this.router.events
@@ -122,10 +116,6 @@ export class PopupViewCacheService implements ViewCacheService {
}
private updateState(key: string, value: string) {
if (!this.featureEnabled) {
return;
}
this.messageSender.send(SAVE_VIEW_CACHE_COMMAND, {
key,
value,

View File

@@ -206,21 +206,4 @@ describe("popup view cache", () => {
expect(messageSenderMock.send).toHaveBeenCalledWith(ClEAR_VIEW_CACHE_COMMAND, {});
expect(service["_cache"]).toEqual({});
});
it("should ignore cached values when feature flag is off", async () => {
jest.spyOn(configServiceMock, "getFeatureFlag").mockResolvedValue(false);
await initServiceWithState({ "foo-123": JSON.stringify("bar") });
const injector = TestBed.inject(Injector);
const signal = service.signal({
key: "foo-123",
initialValue: "foo",
injector,
});
// The cached state is ignored
expect(signal()).toBe("foo");
});
});

View File

@@ -30,7 +30,6 @@ export enum FeatureFlag {
AC1795_UpdatedSubscriptionStatusSection = "AC-1795_updated-subscription-status-section",
ExtensionRefresh = "extension-refresh",
PersistPopupView = "persist-popup-view",
PM4154_BulkEncryptionService = "PM-4154-bulk-encryption-service",
VaultBulkManagementAction = "vault-bulk-management-action",
UnauthenticatedExtensionUIRefresh = "unauth-ui-refresh",
@@ -89,7 +88,6 @@ export const DefaultFeatureFlagValue = {
[FeatureFlag.AC1795_UpdatedSubscriptionStatusSection]: FALSE,
[FeatureFlag.ExtensionRefresh]: FALSE,
[FeatureFlag.PersistPopupView]: FALSE,
[FeatureFlag.PM4154_BulkEncryptionService]: FALSE,
[FeatureFlag.VaultBulkManagementAction]: FALSE,
[FeatureFlag.UnauthenticatedExtensionUIRefresh]: FALSE,