1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 18:23:31 +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

@@ -69,6 +69,7 @@ export class LockComponent extends BaseLockComponent {
const forcePasswordReset = await this.stateService.getForcePasswordReset();
this.successRoute = forcePasswordReset === true ? this.unAuthenicatedUrl : this.authenicatedUrl;
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
this.route.queryParams.subscribe((params) => {
if (this.supportsBiometric && params.promptBiometric && autoPromptBiometric) {
setTimeout(async () => {

View File

@@ -102,13 +102,16 @@ export class LoginComponent extends BaseLoginComponent implements OnDestroy {
this.environmentModal
);
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
modal.onShown.subscribe(() => {
this.showingModal = true;
});
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
modal.onClosed.subscribe(() => {
this.showingModal = false;
});
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
childComponent.onSaved.subscribe(() => {
modal.close();
});

View File

@@ -24,6 +24,7 @@ import { DeleteAccountComponent } from "./delete-account.component";
selector: "app-settings",
templateUrl: "settings.component.html",
})
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class SettingsComponent implements OnInit {
vaultTimeoutAction: string;
pin: boolean = null;
@@ -178,6 +179,7 @@ export class SettingsComponent implements OnInit {
this.vaultTimeout.setValue(await this.stateService.getVaultTimeout());
this.vaultTimeoutAction = await this.stateService.getVaultTimeoutAction();
this.previousVaultTimeout = this.vaultTimeout.value;
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
this.vaultTimeout.valueChanges.pipe(debounceTime(500)).subscribe(() => {
this.saveVaultTimeoutOptions();
});

View File

@@ -21,6 +21,7 @@ import { TwoFactorOptionsComponent } from "./two-factor-options.component";
selector: "app-two-factor",
templateUrl: "two-factor.component.html",
})
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class TwoFactorComponent extends BaseTwoFactorComponent {
@ViewChild("twoFactorOptions", { read: ViewContainerRef, static: true })
twoFactorOptionsModal: ViewContainerRef;
@@ -67,18 +68,22 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
this.twoFactorOptionsModal
);
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
modal.onShown.subscribe(() => {
this.showingModal = true;
});
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
modal.onClosed.subscribe(() => {
this.showingModal = false;
});
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
childComponent.onProviderSelected.subscribe(async (provider: TwoFactorProviderType) => {
modal.close();
this.selectedProviderType = provider;
await this.init();
});
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
childComponent.onRecoverSelected.subscribe(() => {
modal.close();
});

View File

@@ -98,7 +98,7 @@ export class AppComponent implements OnInit, OnDestroy {
private isIdle = false;
private activeUserId: string = null;
private destroy$: Subject<void> = new Subject<void>();
private destroy$ = new Subject<void>();
constructor(
private broadcasterService: BroadcasterService,
@@ -377,10 +377,12 @@ export class AppComponent implements OnInit, OnDestroy {
);
this.modal = modal;
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
childComponent.onSaved.subscribe(() => {
this.modal.close();
});
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
this.modal.onClosed.subscribe(() => {
this.modal = null;
});
@@ -396,11 +398,13 @@ export class AppComponent implements OnInit, OnDestroy {
);
this.modal = modal;
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
childComponent.onSavedFolder.subscribe(async () => {
this.modal.close();
this.syncService.fullSync(false);
});
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
this.modal.onClosed.subscribe(() => {
this.modal = null;
});
@@ -415,6 +419,7 @@ export class AppComponent implements OnInit, OnDestroy {
(comp) => (comp.comingFromAddEdit = false)
);
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
this.modal.onClosed.subscribe(() => {
this.modal = null;
});
@@ -539,6 +544,7 @@ export class AppComponent implements OnInit, OnDestroy {
[this.modal] = await this.modalService.openViewRef(type, ref);
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
this.modal.onClosed.subscribe(() => {
this.modal = null;
});

View File

@@ -48,6 +48,7 @@ export class SwitcherAccount extends Account {
]),
],
})
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class AccountSwitcherComponent implements OnInit {
isOpen = false;
accounts: { [userId: string]: SwitcherAccount } = {};
@@ -84,6 +85,7 @@ export class AccountSwitcherComponent implements OnInit {
) {}
async ngOnInit(): Promise<void> {
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
this.stateService.accounts.subscribe(async (accounts: { [userId: string]: Account }) => {
for (const userId in accounts) {
accounts[userId].profile.authenticationStatus = await this.authService.getAuthStatus(

View File

@@ -17,16 +17,19 @@ export class SearchComponent implements OnInit, OnDestroy {
private activeAccountSubscription: Subscription;
constructor(private searchBarService: SearchBarService, private stateService: StateService) {
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
this.searchBarService.state$.subscribe((state) => {
this.state = state;
});
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
this.searchText.valueChanges.subscribe((value) => {
this.searchBarService.setSearchText(value);
});
}
ngOnInit() {
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
this.activeAccountSubscription = this.stateService.activeAccount$.subscribe((value) => {
this.searchBarService.setSearchText("");
this.searchText.patchValue("");

View File

@@ -56,6 +56,7 @@ export class SendComponent extends BaseSendComponent implements OnInit, OnDestro
policyService,
logService
);
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
this.searchBarService.searchText$.subscribe((searchText) => {
this.searchText = searchText;
this.searchTextChanged();

View File

@@ -10,10 +10,12 @@ import { SearchBarService } from "../layout/search/search-bar.service";
selector: "app-vault-ciphers",
templateUrl: "ciphers.component.html",
})
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class CiphersComponent extends BaseCiphersComponent {
constructor(searchService: SearchService, searchBarService: SearchBarService) {
super(searchService);
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
searchBarService.searchText$.subscribe((searchText) => {
this.searchText = searchText;
this.search(200);

View File

@@ -216,6 +216,7 @@ export class VaultComponent implements OnInit, OnDestroy {
}
async load() {
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
this.route.queryParams.pipe(first()).subscribe(async (params) => {
if (params.cipherId) {
const cipherView = new CipherView();
@@ -458,9 +459,12 @@ export class VaultComponent implements OnInit, OnDestroy {
this.modal = modal;
let madeAttachmentChanges = false;
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
childComponent.onUploadedAttachment.subscribe(() => (madeAttachmentChanges = true));
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
childComponent.onDeletedAttachment.subscribe(() => (madeAttachmentChanges = true));
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
this.modal.onClosed.subscribe(async () => {
this.modal = null;
if (madeAttachmentChanges) {
@@ -482,11 +486,13 @@ export class VaultComponent implements OnInit, OnDestroy {
);
this.modal = modal;
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
childComponent.onSharedCipher.subscribe(async () => {
this.modal.close();
this.viewCipher(cipher);
await this.ciphersComponent.refresh();
});
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
this.modal.onClosed.subscribe(async () => {
this.modal = null;
});
@@ -504,10 +510,12 @@ export class VaultComponent implements OnInit, OnDestroy {
);
this.modal = modal;
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
childComponent.onSavedCollections.subscribe(() => {
this.modal.close();
this.viewCipher(cipher);
});
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
this.modal.onClosed.subscribe(async () => {
this.modal = null;
});
@@ -524,6 +532,7 @@ export class VaultComponent implements OnInit, OnDestroy {
(comp) => (comp.cipherId = cipher.id)
);
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
this.modal.onClosed.subscribe(async () => {
this.modal = null;
});
@@ -596,6 +605,7 @@ export class VaultComponent implements OnInit, OnDestroy {
);
this.modal = modal;
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
childComponent.onSelected.subscribe((value: string) => {
this.modal.close();
if (loginType) {
@@ -608,6 +618,7 @@ export class VaultComponent implements OnInit, OnDestroy {
}
});
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
this.modal.onClosed.subscribe(() => {
this.modal = null;
});
@@ -629,15 +640,18 @@ export class VaultComponent implements OnInit, OnDestroy {
);
this.modal = modal;
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
childComponent.onSavedFolder.subscribe(async (folder: FolderView) => {
this.modal.close();
await this.vaultFilterComponent.reloadCollectionsAndFolders(this.activeFilter);
});
// eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe
childComponent.onDeletedFolder.subscribe(async (folder: FolderView) => {
this.modal.close();
await this.vaultFilterComponent.reloadCollectionsAndFolders(this.activeFilter);
});
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
this.modal.onClosed.subscribe(() => {
this.modal = null;
});