1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 13:23:34 +00:00

Add eslint-plugin-rxjs & rxjs-angular (#3373)

This commit is contained in:
Oscar Hinton
2022-08-26 18:09:28 +02:00
committed by GitHub
parent feb6e67bc4
commit e7c7037a14
102 changed files with 866 additions and 49 deletions

View File

@@ -80,6 +80,7 @@ export class GeneratorComponent implements OnInit {
}
async ngOnInit() {
// eslint-disable-next-line rxjs/no-async-subscribe
this.route.queryParams.pipe(first()).subscribe(async (qParams) => {
const passwordOptionsResponse = await this.passwordGenerationService.getOptions();
this.passwordOptions = passwordOptionsResponse[0];

View File

@@ -58,6 +58,7 @@ export class LockComponent implements OnInit, OnDestroy {
) {}
async ngOnInit() {
// eslint-disable-next-line rxjs/no-async-subscribe
this.activeAccountSubscription = this.stateService.activeAccount$.subscribe(async () => {
await this.load();
});

View File

@@ -66,6 +66,7 @@ export class SetPasswordComponent extends BaseChangePasswordComponent {
await this.syncService.fullSync(true);
this.syncLoading = false;
// eslint-disable-next-line rxjs/no-async-subscribe
this.route.queryParams.pipe(first()).subscribe(async (qParams) => {
if (qParams.identifier != null) {
this.identifier = qParams.identifier;

View File

@@ -66,6 +66,7 @@ export class VaultTimeoutInputComponent implements ControlValueAccessor, Validat
this.validatorChange();
}
// eslint-disable-next-line rxjs/no-async-subscribe
this.form.valueChanges.subscribe(async (value) => {
this.onChange(this.getVaultTimeout(value));
});

View File

@@ -53,6 +53,7 @@ export class SsoComponent {
) {}
async ngOnInit() {
// eslint-disable-next-line rxjs/no-async-subscribe
this.route.queryParams.pipe(first()).subscribe(async (qParams) => {
if (qParams.code != null && qParams.state != null) {
const codeVerifier = await this.stateService.getSsoCodeVerifier();

View File

@@ -30,6 +30,7 @@ import { Verification } from "@bitwarden/common/types/verification";
]),
],
})
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class UserVerificationComponent implements ControlValueAccessor, OnInit {
usesKeyConnector = false;
disableRequestOTP = false;
@@ -48,6 +49,7 @@ export class UserVerificationComponent implements ControlValueAccessor, OnInit {
this.usesKeyConnector = await this.keyConnectorService.getUsesKeyConnector();
this.processChanges(this.secret.value);
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
this.secret.valueChanges.subscribe((secret: string) => this.processChanges(secret));
}

View File

@@ -1,4 +1,4 @@
import { Observable, Subject } from "rxjs";
import { concatMap, Observable, Subject } from "rxjs";
import {
EnvironmentService as EnvironmentServiceAbstraction,
@@ -22,9 +22,13 @@ export class EnvironmentService implements EnvironmentServiceAbstraction {
private scimUrl: string = null;
constructor(private stateService: StateService) {
this.stateService.activeAccount$.subscribe(async () => {
await this.setUrlsFromStorage();
});
this.stateService.activeAccount$
.pipe(
concatMap(async () => {
await this.setUrlsFromStorage();
})
)
.subscribe();
}
hasBaseUrl() {

View File

@@ -1,4 +1,4 @@
import { BehaviorSubject } from "rxjs";
import { BehaviorSubject, concatMap } from "rxjs";
import { CipherService } from "../../abstractions/cipher.service";
import { CryptoService } from "../../abstractions/crypto.service";
@@ -25,21 +25,25 @@ export class FolderService implements InternalFolderServiceAbstraction {
private cipherService: CipherService,
private stateService: StateService
) {
this.stateService.activeAccountUnlocked$.subscribe(async (unlocked) => {
if (Utils.global.bitwardenContainerService == null) {
return;
}
this.stateService.activeAccountUnlocked$
.pipe(
concatMap(async (unlocked) => {
if (Utils.global.bitwardenContainerService == null) {
return;
}
if (!unlocked) {
this._folders.next([]);
this._folderViews.next([]);
return;
}
if (!unlocked) {
this._folders.next([]);
this._folderViews.next([]);
return;
}
const data = await this.stateService.getEncryptedFolders();
const data = await this.stateService.getEncryptedFolders();
await this.updateObservables(data);
});
await this.updateObservables(data);
})
)
.subscribe();
}
async clearCache(): Promise<void> {

View File

@@ -1,4 +1,4 @@
import { BehaviorSubject } from "rxjs";
import { BehaviorSubject, concatMap } from "rxjs";
import { LogService } from "../abstractions/log.service";
import { StateService as StateServiceAbstraction } from "../abstractions/state.service";
@@ -76,18 +76,22 @@ export class StateService<
protected useAccountCache: boolean = true
) {
// If the account gets changed, verify the new account is unlocked
this.activeAccountSubject.subscribe(async (userId) => {
if (userId == null && this.activeAccountUnlockedSubject.getValue() == false) {
return;
} else if (userId == null) {
this.activeAccountUnlockedSubject.next(false);
}
this.activeAccountSubject
.pipe(
concatMap(async (userId) => {
if (userId == null && this.activeAccountUnlockedSubject.getValue() == false) {
return;
} else if (userId == null) {
this.activeAccountUnlockedSubject.next(false);
}
// FIXME: This should be refactored into AuthService or a similar service,
// as checking for the existance of the crypto key is a low level
// implementation detail.
this.activeAccountUnlockedSubject.next((await this.getCryptoMasterKey()) != null);
});
// FIXME: This should be refactored into AuthService or a similar service,
// as checking for the existance of the crypto key is a low level
// implementation detail.
this.activeAccountUnlockedSubject.next((await this.getCryptoMasterKey()) != null);
})
)
.subscribe();
}
async init(): Promise<void> {