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:
@@ -9,10 +9,8 @@ import {
|
|||||||
Router,
|
Router,
|
||||||
UrlSerializer,
|
UrlSerializer,
|
||||||
} from "@angular/router";
|
} 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 { GlobalStateProvider } from "@bitwarden/common/platform/state";
|
||||||
|
|
||||||
import { POPUP_ROUTE_HISTORY_KEY } from "../../../platform/services/popup-view-cache-background.service";
|
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.
|
* Redirect to the last visited route. Should be applied to root route.
|
||||||
*
|
|
||||||
* If `FeatureFlag.PersistPopupView` is disabled, do nothing.
|
|
||||||
**/
|
**/
|
||||||
export const popupRouterCacheGuard = (() => {
|
export const popupRouterCacheGuard = (() => {
|
||||||
const configService = inject(ConfigService);
|
|
||||||
const popupHistoryService = inject(PopupRouterCacheService);
|
const popupHistoryService = inject(PopupRouterCacheService);
|
||||||
const urlSerializer = inject(UrlSerializer);
|
const urlSerializer = inject(UrlSerializer);
|
||||||
|
|
||||||
return configService.getFeatureFlag$(FeatureFlag.PersistPopupView).pipe(
|
return popupHistoryService.last$().pipe(
|
||||||
switchMap((featureEnabled) => {
|
map((url: string) => {
|
||||||
if (!featureEnabled) {
|
if (!url) {
|
||||||
return of(true);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return popupHistoryService.last$().pipe(
|
return urlSerializer.parse(url);
|
||||||
map((url: string) => {
|
|
||||||
if (!url) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return urlSerializer.parse(url);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}) satisfies CanActivateFn;
|
}) satisfies CanActivateFn;
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ import {
|
|||||||
SignalCacheOptions,
|
SignalCacheOptions,
|
||||||
ViewCacheService,
|
ViewCacheService,
|
||||||
} from "@bitwarden/angular/platform/abstractions/view-cache.service";
|
} 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 { MessageSender } from "@bitwarden/common/platform/messaging";
|
||||||
import { GlobalStateProvider } from "@bitwarden/common/platform/state";
|
import { GlobalStateProvider } from "@bitwarden/common/platform/state";
|
||||||
|
|
||||||
@@ -40,13 +38,10 @@ import {
|
|||||||
providedIn: "root",
|
providedIn: "root",
|
||||||
})
|
})
|
||||||
export class PopupViewCacheService implements ViewCacheService {
|
export class PopupViewCacheService implements ViewCacheService {
|
||||||
private configService = inject(ConfigService);
|
|
||||||
private globalStateProvider = inject(GlobalStateProvider);
|
private globalStateProvider = inject(GlobalStateProvider);
|
||||||
private messageSender = inject(MessageSender);
|
private messageSender = inject(MessageSender);
|
||||||
private router = inject(Router);
|
private router = inject(Router);
|
||||||
|
|
||||||
private featureEnabled: boolean;
|
|
||||||
|
|
||||||
private _cache: Record<string, string>;
|
private _cache: Record<string, string>;
|
||||||
private get cache(): Record<string, string> {
|
private get cache(): Record<string, string> {
|
||||||
if (!this._cache) {
|
if (!this._cache) {
|
||||||
@@ -59,10 +54,9 @@ export class PopupViewCacheService implements ViewCacheService {
|
|||||||
* Initialize the service. This should only be called once.
|
* Initialize the service. This should only be called once.
|
||||||
*/
|
*/
|
||||||
async init() {
|
async init() {
|
||||||
this.featureEnabled = await this.configService.getFeatureFlag(FeatureFlag.PersistPopupView);
|
const initialState = await firstValueFrom(
|
||||||
const initialState = this.featureEnabled
|
this.globalStateProvider.get(POPUP_VIEW_CACHE_KEY).state$,
|
||||||
? await firstValueFrom(this.globalStateProvider.get(POPUP_VIEW_CACHE_KEY).state$)
|
);
|
||||||
: {};
|
|
||||||
this._cache = Object.freeze(initialState ?? {});
|
this._cache = Object.freeze(initialState ?? {});
|
||||||
|
|
||||||
this.router.events
|
this.router.events
|
||||||
@@ -122,10 +116,6 @@ export class PopupViewCacheService implements ViewCacheService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private updateState(key: string, value: string) {
|
private updateState(key: string, value: string) {
|
||||||
if (!this.featureEnabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.messageSender.send(SAVE_VIEW_CACHE_COMMAND, {
|
this.messageSender.send(SAVE_VIEW_CACHE_COMMAND, {
|
||||||
key,
|
key,
|
||||||
value,
|
value,
|
||||||
|
|||||||
@@ -206,21 +206,4 @@ describe("popup view cache", () => {
|
|||||||
expect(messageSenderMock.send).toHaveBeenCalledWith(ClEAR_VIEW_CACHE_COMMAND, {});
|
expect(messageSenderMock.send).toHaveBeenCalledWith(ClEAR_VIEW_CACHE_COMMAND, {});
|
||||||
expect(service["_cache"]).toEqual({});
|
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");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ export enum FeatureFlag {
|
|||||||
|
|
||||||
AC1795_UpdatedSubscriptionStatusSection = "AC-1795_updated-subscription-status-section",
|
AC1795_UpdatedSubscriptionStatusSection = "AC-1795_updated-subscription-status-section",
|
||||||
ExtensionRefresh = "extension-refresh",
|
ExtensionRefresh = "extension-refresh",
|
||||||
PersistPopupView = "persist-popup-view",
|
|
||||||
PM4154_BulkEncryptionService = "PM-4154-bulk-encryption-service",
|
PM4154_BulkEncryptionService = "PM-4154-bulk-encryption-service",
|
||||||
VaultBulkManagementAction = "vault-bulk-management-action",
|
VaultBulkManagementAction = "vault-bulk-management-action",
|
||||||
UnauthenticatedExtensionUIRefresh = "unauth-ui-refresh",
|
UnauthenticatedExtensionUIRefresh = "unauth-ui-refresh",
|
||||||
@@ -89,7 +88,6 @@ export const DefaultFeatureFlagValue = {
|
|||||||
|
|
||||||
[FeatureFlag.AC1795_UpdatedSubscriptionStatusSection]: FALSE,
|
[FeatureFlag.AC1795_UpdatedSubscriptionStatusSection]: FALSE,
|
||||||
[FeatureFlag.ExtensionRefresh]: FALSE,
|
[FeatureFlag.ExtensionRefresh]: FALSE,
|
||||||
[FeatureFlag.PersistPopupView]: FALSE,
|
|
||||||
[FeatureFlag.PM4154_BulkEncryptionService]: FALSE,
|
[FeatureFlag.PM4154_BulkEncryptionService]: FALSE,
|
||||||
[FeatureFlag.VaultBulkManagementAction]: FALSE,
|
[FeatureFlag.VaultBulkManagementAction]: FALSE,
|
||||||
[FeatureFlag.UnauthenticatedExtensionUIRefresh]: FALSE,
|
[FeatureFlag.UnauthenticatedExtensionUIRefresh]: FALSE,
|
||||||
|
|||||||
Reference in New Issue
Block a user