mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-29 12:55:21 +01:00
Merge branch 'main' into vault/pm-5273
This commit is contained in:
commit
f1556287e7
@ -349,13 +349,12 @@ import { ModalService } from "./modal.service";
|
|||||||
provide: CipherServiceAbstraction,
|
provide: CipherServiceAbstraction,
|
||||||
useFactory: (
|
useFactory: (
|
||||||
cryptoService: CryptoServiceAbstraction,
|
cryptoService: CryptoServiceAbstraction,
|
||||||
settingsService: SettingsServiceAbstraction,
|
domainSettingsService: DomainSettingsService,
|
||||||
apiService: ApiServiceAbstraction,
|
apiService: ApiServiceAbstraction,
|
||||||
i18nService: I18nServiceAbstraction,
|
i18nService: I18nServiceAbstraction,
|
||||||
searchService: SearchServiceAbstraction,
|
searchService: SearchServiceAbstraction,
|
||||||
stateService: StateServiceAbstraction,
|
stateService: StateServiceAbstraction,
|
||||||
autofillSettingsService: AutofillSettingsServiceAbstraction,
|
autofillSettingsService: AutofillSettingsServiceAbstraction,
|
||||||
domainSettingsService: DomainSettingsService,
|
|
||||||
encryptService: EncryptService,
|
encryptService: EncryptService,
|
||||||
fileUploadService: CipherFileUploadServiceAbstraction,
|
fileUploadService: CipherFileUploadServiceAbstraction,
|
||||||
configService: ConfigServiceAbstraction,
|
configService: ConfigServiceAbstraction,
|
||||||
@ -376,7 +375,7 @@ import { ModalService } from "./modal.service";
|
|||||||
),
|
),
|
||||||
deps: [
|
deps: [
|
||||||
CryptoServiceAbstraction,
|
CryptoServiceAbstraction,
|
||||||
SettingsServiceAbstraction,
|
DomainSettingsService,
|
||||||
ApiServiceAbstraction,
|
ApiServiceAbstraction,
|
||||||
I18nServiceAbstraction,
|
I18nServiceAbstraction,
|
||||||
SearchServiceAbstraction,
|
SearchServiceAbstraction,
|
||||||
|
@ -25,6 +25,7 @@ import {
|
|||||||
FakeGlobalState,
|
FakeGlobalState,
|
||||||
FakeSingleUserState,
|
FakeSingleUserState,
|
||||||
} from "./fake-state";
|
} from "./fake-state";
|
||||||
|
import { isUserKeyDefinition } from "../src/platform/state/user-key-definition";
|
||||||
|
|
||||||
export class FakeGlobalStateProvider implements GlobalStateProvider {
|
export class FakeGlobalStateProvider implements GlobalStateProvider {
|
||||||
mock = mock<GlobalStateProvider>();
|
mock = mock<GlobalStateProvider>();
|
||||||
@ -95,7 +96,10 @@ export class FakeSingleUserStateProvider implements SingleUserStateProvider {
|
|||||||
return result as SingleUserState<T>;
|
return result as SingleUserState<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
getFake<T>(userId: UserId, keyDefinition: KeyDefinition<T>): FakeSingleUserState<T> {
|
getFake<T>(
|
||||||
|
userId: UserId,
|
||||||
|
keyDefinition: KeyDefinition<T> | UserKeyDefinition<T>,
|
||||||
|
): FakeSingleUserState<T> {
|
||||||
return this.get(userId, keyDefinition) as FakeSingleUserState<T>;
|
return this.get(userId, keyDefinition) as FakeSingleUserState<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +141,7 @@ export class FakeActiveUserStateProvider implements ActiveUserStateProvider {
|
|||||||
return result as ActiveUserState<T>;
|
return result as ActiveUserState<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
getFake<T>(keyDefinition: KeyDefinition<T>): FakeActiveUserState<T> {
|
getFake<T>(keyDefinition: KeyDefinition<T> | UserKeyDefinition<T>): FakeActiveUserState<T> {
|
||||||
return this.get(keyDefinition) as FakeActiveUserState<T>;
|
return this.get(keyDefinition) as FakeActiveUserState<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,8 +158,15 @@ export class FakeActiveUserStateProvider implements ActiveUserStateProvider {
|
|||||||
|
|
||||||
export class FakeStateProvider implements StateProvider {
|
export class FakeStateProvider implements StateProvider {
|
||||||
mock = mock<StateProvider>();
|
mock = mock<StateProvider>();
|
||||||
getUserState$<T>(keyDefinition: KeyDefinition<T>, userId?: UserId): Observable<T> {
|
getUserState$<T>(
|
||||||
this.mock.getUserState$(keyDefinition, userId);
|
keyDefinition: KeyDefinition<T> | UserKeyDefinition<T>,
|
||||||
|
userId?: UserId,
|
||||||
|
): Observable<T> {
|
||||||
|
if (isUserKeyDefinition(keyDefinition)) {
|
||||||
|
this.mock.getUserState$(keyDefinition, userId);
|
||||||
|
} else {
|
||||||
|
this.mock.getUserState$(keyDefinition, userId);
|
||||||
|
}
|
||||||
if (userId) {
|
if (userId) {
|
||||||
return this.getUser<T>(userId, keyDefinition).state$;
|
return this.getUser<T>(userId, keyDefinition).state$;
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,22 @@ import { ActiveUserStateProvider, SingleUserStateProvider } from "./user-state.p
|
|||||||
* and {@link GlobalStateProvider}.
|
* and {@link GlobalStateProvider}.
|
||||||
*/
|
*/
|
||||||
export abstract class StateProvider {
|
export abstract class StateProvider {
|
||||||
/** @see{@link ActiveUserState.activeUserId$} */
|
/** @see{@link ActiveUserStateProvider.activeUserId$} */
|
||||||
activeUserId$: Observable<UserId | undefined>;
|
activeUserId$: Observable<UserId | undefined>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a state observable for a given key and userId.
|
||||||
|
*
|
||||||
|
* @remarks If userId is falsy the observable returned will point to the currently active user _and not update if the active user changes_.
|
||||||
|
* This is different to how `getActive` works and more similar to `getUser` for whatever user happens to be active at the time of the call.
|
||||||
|
*
|
||||||
|
* @note consider converting your {@link KeyDefinition} to a {@link UserKeyDefinition} for additional features.
|
||||||
|
*
|
||||||
|
* @param keyDefinition - The key definition for the state you want to get.
|
||||||
|
* @param userId - The userId for which you want the state for. If not provided, the state for the currently active user will be returned.
|
||||||
|
*/
|
||||||
|
abstract getUserState$<T>(keyDefinition: KeyDefinition<T>, userId?: UserId): Observable<T>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a state observable for a given key and userId.
|
* Gets a state observable for a given key and userId.
|
||||||
*
|
*
|
||||||
@ -29,7 +43,7 @@ export abstract class StateProvider {
|
|||||||
* @param keyDefinition - The key definition for the state you want to get.
|
* @param keyDefinition - The key definition for the state you want to get.
|
||||||
* @param userId - The userId for which you want the state for. If not provided, the state for the currently active user will be returned.
|
* @param userId - The userId for which you want the state for. If not provided, the state for the currently active user will be returned.
|
||||||
*/
|
*/
|
||||||
getUserState$: <T>(keyDefinition: KeyDefinition<T>, userId?: UserId) => Observable<T>;
|
abstract getUserState$<T>(keyDefinition: UserKeyDefinition<T>, userId?: UserId): Observable<T>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the state for a given key and userId.
|
* Sets the state for a given key and userId.
|
||||||
|
Loading…
Reference in New Issue
Block a user