1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-06 10:33:57 +00:00
Files
browser/apps/web/src/app/platform/web-storage-service.provider.ts
Justin Baur 5f7f1d1924 Resolve state <-> state-test-utils circular dependency (#16093)
* Resolve state <-> state-test-utils circular dependency

* Fix type errors
2025-08-25 12:38:28 -04:00

33 lines
1.1 KiB
TypeScript

import {
AbstractStorageService,
ClientLocations,
ObservableStorageService,
PossibleLocation,
StorageServiceProvider,
} from "@bitwarden/storage-core";
export class WebStorageServiceProvider extends StorageServiceProvider {
constructor(
diskStorageService: AbstractStorageService & ObservableStorageService,
memoryStorageService: AbstractStorageService & ObservableStorageService,
private readonly diskLocalStorageService: AbstractStorageService & ObservableStorageService,
) {
super(diskStorageService, memoryStorageService);
}
override get(
defaultLocation: PossibleLocation,
overrides: Partial<ClientLocations>,
): [location: PossibleLocation, service: AbstractStorageService & ObservableStorageService] {
const location = overrides["web"] ?? defaultLocation;
switch (location) {
case "disk-local":
return ["disk-local", this.diskLocalStorageService];
default:
// Pass in computed location to super because they could have
// overriden default "disk" with web "memory".
return super.get(location, overrides);
}
}
}