mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-11 00:31:45 +01:00
[Refactor] Use rxjs first instead of unsubscribe from queryParams (#2112)
* Use rxjs first instead of unsubscribe * Update jslib
This commit is contained in:
parent
2c2de6a233
commit
82138a08ff
2
jslib
2
jslib
@ -1 +1 @@
|
|||||||
Subproject commit 764dc40b36e0000807e59b8d6feea5ac4577270d
|
Subproject commit a20e935268c986538ff68f72016bb8c772ea3a1b
|
@ -9,6 +9,8 @@ import {
|
|||||||
Router,
|
Router,
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
|
|
||||||
|
import { first } from 'rxjs/operators';
|
||||||
|
|
||||||
import { TwoFactorProviderType } from 'jslib-common/enums/twoFactorProviderType';
|
import { TwoFactorProviderType } from 'jslib-common/enums/twoFactorProviderType';
|
||||||
|
|
||||||
import { ApiService } from 'jslib-common/abstractions/api.service';
|
import { ApiService } from 'jslib-common/abstractions/api.service';
|
||||||
@ -89,7 +91,7 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const queryParamsSub = this.route.queryParams.subscribe(async qParams => {
|
this.route.queryParams.pipe(first()).subscribe(async qParams => {
|
||||||
if (qParams.sso === 'true') {
|
if (qParams.sso === 'true') {
|
||||||
super.onSuccessfulLogin = () => {
|
super.onSuccessfulLogin = () => {
|
||||||
BrowserApi.reloadOpenWindows();
|
BrowserApi.reloadOpenWindows();
|
||||||
@ -97,9 +99,6 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
|
|||||||
thisWindow.close();
|
thisWindow.close();
|
||||||
return this.syncService.fullSync(true);
|
return this.syncService.fullSync(true);
|
||||||
};
|
};
|
||||||
if (queryParamsSub != null) {
|
|
||||||
queryParamsSub.unsubscribe();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ import {
|
|||||||
Router,
|
Router,
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
|
|
||||||
|
import { first } from 'rxjs/operators';
|
||||||
|
|
||||||
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
|
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
|
||||||
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
||||||
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
|
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
|
||||||
@ -79,7 +81,7 @@ export class SendAddEditComponent extends BaseAddEditComponent {
|
|||||||
this.isLinux = window?.navigator?.userAgent.indexOf('Linux') !== -1;
|
this.isLinux = window?.navigator?.userAgent.indexOf('Linux') !== -1;
|
||||||
this.isUnsupportedMac = this.platformUtilsService.isChrome() && window?.navigator?.appVersion.includes('Mac OS X 11');
|
this.isUnsupportedMac = this.platformUtilsService.isChrome() && window?.navigator?.appVersion.includes('Mac OS X 11');
|
||||||
|
|
||||||
const queryParamsSub = this.route.queryParams.subscribe(async params => {
|
this.route.queryParams.pipe(first()).subscribe(async params => {
|
||||||
if (params.sendId) {
|
if (params.sendId) {
|
||||||
this.sendId = params.sendId;
|
this.sendId = params.sendId;
|
||||||
}
|
}
|
||||||
@ -88,10 +90,6 @@ export class SendAddEditComponent extends BaseAddEditComponent {
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
await this.load();
|
await this.load();
|
||||||
|
|
||||||
if (queryParamsSub != null) {
|
|
||||||
queryParamsSub.unsubscribe();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
|
@ -9,6 +9,8 @@ import {
|
|||||||
Router,
|
Router,
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
|
|
||||||
|
import { first } from 'rxjs/operators';
|
||||||
|
|
||||||
import { Location } from '@angular/common';
|
import { Location } from '@angular/common';
|
||||||
|
|
||||||
import { SendView } from 'jslib-common/models/view/sendView';
|
import { SendView } from 'jslib-common/models/view/sendView';
|
||||||
@ -61,7 +63,7 @@ export class SendTypeComponent extends BaseSendComponent {
|
|||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
// Let super class finish
|
// Let super class finish
|
||||||
await super.ngOnInit();
|
await super.ngOnInit();
|
||||||
const queryParamsSub = this.route.queryParams.subscribe(async params => {
|
this.route.queryParams.pipe(first()).subscribe(async params => {
|
||||||
if (this.applySavedState) {
|
if (this.applySavedState) {
|
||||||
this.state = (await this.stateService.get<any>(ComponentId)) || {};
|
this.state = (await this.stateService.get<any>(ComponentId)) || {};
|
||||||
if (this.state.searchText != null) {
|
if (this.state.searchText != null) {
|
||||||
@ -89,11 +91,6 @@ export class SendTypeComponent extends BaseSendComponent {
|
|||||||
window.setTimeout(() => this.popupUtils.setContentScrollY(window, this.state.scrollY), 0);
|
window.setTimeout(() => this.popupUtils.setContentScrollY(window, this.state.scrollY), 0);
|
||||||
}
|
}
|
||||||
this.stateService.remove(ComponentId);
|
this.stateService.remove(ComponentId);
|
||||||
|
|
||||||
// Unsubscribe
|
|
||||||
if (queryParamsSub != null) {
|
|
||||||
queryParamsSub.unsubscribe();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Refresh Send list if sync completed in background
|
// Refresh Send list if sync completed in background
|
||||||
|
@ -4,6 +4,8 @@ import {
|
|||||||
Router,
|
Router,
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
|
|
||||||
|
import { first } from 'rxjs/operators';
|
||||||
|
|
||||||
import { FolderService } from 'jslib-common/abstractions/folder.service';
|
import { FolderService } from 'jslib-common/abstractions/folder.service';
|
||||||
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
||||||
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
||||||
@ -24,14 +26,11 @@ export class FolderAddEditComponent extends BaseFolderAddEditComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
const queryParamsSub = this.route.queryParams.subscribe(async params => {
|
this.route.queryParams.pipe(first()).subscribe(async params => {
|
||||||
if (params.folderId) {
|
if (params.folderId) {
|
||||||
this.folderId = params.folderId;
|
this.folderId = params.folderId;
|
||||||
}
|
}
|
||||||
await this.init();
|
await this.init();
|
||||||
if (queryParamsSub != null) {
|
|
||||||
queryParamsSub.unsubscribe();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ import {
|
|||||||
Router,
|
Router,
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
|
|
||||||
|
import { first } from 'rxjs/operators';
|
||||||
|
|
||||||
import { BrowserApi } from '../../browser/browserApi';
|
import { BrowserApi } from '../../browser/browserApi';
|
||||||
|
|
||||||
import { AuditService } from 'jslib-common/abstractions/audit.service';
|
import { AuditService } from 'jslib-common/abstractions/audit.service';
|
||||||
@ -54,7 +56,7 @@ export class AddEditComponent extends BaseAddEditComponent {
|
|||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
await super.ngOnInit();
|
await super.ngOnInit();
|
||||||
|
|
||||||
const queryParamsSub = this.route.queryParams.subscribe(async params => {
|
this.route.queryParams.pipe(first()).subscribe(async params => {
|
||||||
if (params.cipherId) {
|
if (params.cipherId) {
|
||||||
this.cipherId = params.cipherId;
|
this.cipherId = params.cipherId;
|
||||||
}
|
}
|
||||||
@ -89,9 +91,6 @@ export class AddEditComponent extends BaseAddEditComponent {
|
|||||||
this.cipher.login.uris[0].uri = params.uri;
|
this.cipher.login.uris[0].uri = params.uri;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (queryParamsSub != null) {
|
|
||||||
queryParamsSub.unsubscribe();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.openAttachmentsInPopup = this.popupUtilsService.inPopup(window);
|
this.openAttachmentsInPopup = this.popupUtilsService.inPopup(window);
|
||||||
});
|
});
|
||||||
|
@ -2,6 +2,8 @@ import { Location } from '@angular/common';
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
|
||||||
|
import { first } from 'rxjs/operators';
|
||||||
|
|
||||||
import { ApiService } from 'jslib-common/abstractions/api.service';
|
import { ApiService } from 'jslib-common/abstractions/api.service';
|
||||||
import { CipherService } from 'jslib-common/abstractions/cipher.service';
|
import { CipherService } from 'jslib-common/abstractions/cipher.service';
|
||||||
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
|
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
|
||||||
@ -26,12 +28,9 @@ export class AttachmentsComponent extends BaseAttachmentsComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
const queryParamsSub = this.route.queryParams.subscribe(async params => {
|
this.route.queryParams.pipe(first()).subscribe(async params => {
|
||||||
this.cipherId = params.cipherId;
|
this.cipherId = params.cipherId;
|
||||||
await this.init();
|
await this.init();
|
||||||
if (queryParamsSub != null) {
|
|
||||||
queryParamsSub.unsubscribe();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.openedAttachmentsInPopup = history.length === 1;
|
this.openedAttachmentsInPopup = history.length === 1;
|
||||||
|
@ -11,6 +11,8 @@ import {
|
|||||||
Router,
|
Router,
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
|
|
||||||
|
import { first } from 'rxjs/operators';
|
||||||
|
|
||||||
import { BrowserApi } from '../../browser/browserApi';
|
import { BrowserApi } from '../../browser/browserApi';
|
||||||
|
|
||||||
import { CipherService } from 'jslib-common/abstractions/cipher.service';
|
import { CipherService } from 'jslib-common/abstractions/cipher.service';
|
||||||
@ -70,7 +72,7 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On
|
|||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.searchTypeSearch = !this.platformUtilsService.isSafari();
|
this.searchTypeSearch = !this.platformUtilsService.isSafari();
|
||||||
const queryParamsSub = this.route.queryParams.subscribe(async params => {
|
this.route.queryParams.pipe(first()).subscribe(async params => {
|
||||||
if (this.applySavedState) {
|
if (this.applySavedState) {
|
||||||
this.state = (await this.stateService.get<any>(ComponentId)) || {};
|
this.state = (await this.stateService.get<any>(ComponentId)) || {};
|
||||||
if (this.state.searchText) {
|
if (this.state.searchText) {
|
||||||
@ -136,9 +138,6 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On
|
|||||||
this.scrollingContainer), 0);
|
this.scrollingContainer), 0);
|
||||||
}
|
}
|
||||||
this.stateService.remove(ComponentId);
|
this.stateService.remove(ComponentId);
|
||||||
if (queryParamsSub != null) {
|
|
||||||
queryParamsSub.unsubscribe();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.broadcasterService.subscribe(ComponentId, (message: any) => {
|
this.broadcasterService.subscribe(ComponentId, (message: any) => {
|
||||||
|
@ -2,6 +2,8 @@ import { Location } from '@angular/common';
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
|
import { first } from 'rxjs/operators';
|
||||||
|
|
||||||
import { CipherService } from 'jslib-common/abstractions/cipher.service';
|
import { CipherService } from 'jslib-common/abstractions/cipher.service';
|
||||||
import { CollectionService } from 'jslib-common/abstractions/collection.service';
|
import { CollectionService } from 'jslib-common/abstractions/collection.service';
|
||||||
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
||||||
@ -24,12 +26,9 @@ export class CollectionsComponent extends BaseCollectionsComponent {
|
|||||||
this.onSavedCollections.subscribe(() => {
|
this.onSavedCollections.subscribe(() => {
|
||||||
this.back();
|
this.back();
|
||||||
});
|
});
|
||||||
const queryParamsSub = this.route.queryParams.subscribe(async params => {
|
this.route.queryParams.pipe(first()).subscribe(async params => {
|
||||||
this.cipherId = params.cipherId;
|
this.cipherId = params.cipherId;
|
||||||
await this.load();
|
await this.load();
|
||||||
if (queryParamsSub != null) {
|
|
||||||
queryParamsSub.unsubscribe();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@ import {
|
|||||||
Router,
|
Router,
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
|
|
||||||
|
import { first } from 'rxjs/operators';
|
||||||
|
|
||||||
import { BrowserApi } from '../../browser/browserApi';
|
import { BrowserApi } from '../../browser/browserApi';
|
||||||
|
|
||||||
import { CipherType } from 'jslib-common/enums/cipherType';
|
import { CipherType } from 'jslib-common/enums/cipherType';
|
||||||
@ -109,7 +111,7 @@ export class GroupingsComponent extends BaseGroupingsComponent implements OnInit
|
|||||||
});
|
});
|
||||||
|
|
||||||
const restoredScopeState = await this.restoreState();
|
const restoredScopeState = await this.restoreState();
|
||||||
const queryParamsSub = this.route.queryParams.subscribe(async params => {
|
this.route.queryParams.pipe(first()).subscribe(async params => {
|
||||||
this.state = (await this.stateService.get<any>(ComponentId)) || {};
|
this.state = (await this.stateService.get<any>(ComponentId)) || {};
|
||||||
if (this.state.searchText) {
|
if (this.state.searchText) {
|
||||||
this.searchText = this.state.searchText;
|
this.searchText = this.state.searchText;
|
||||||
@ -131,9 +133,6 @@ export class GroupingsComponent extends BaseGroupingsComponent implements OnInit
|
|||||||
if (!this.syncService.syncInProgress || restoredScopeState) {
|
if (!this.syncService.syncInProgress || restoredScopeState) {
|
||||||
window.setTimeout(() => this.popupUtils.setContentScrollY(window, this.state.scrollY), 0);
|
window.setTimeout(() => this.popupUtils.setContentScrollY(window, this.state.scrollY), 0);
|
||||||
}
|
}
|
||||||
if (queryParamsSub != null) {
|
|
||||||
queryParamsSub.unsubscribe();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ import { Location } from '@angular/common';
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
|
import { first } from 'rxjs/operators';
|
||||||
|
|
||||||
import { CipherService } from 'jslib-common/abstractions/cipher.service';
|
import { CipherService } from 'jslib-common/abstractions/cipher.service';
|
||||||
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
||||||
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
||||||
@ -22,16 +24,13 @@ export class PasswordHistoryComponent extends BasePasswordHistoryComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
const queryParamsSub = this.route.queryParams.subscribe(async params => {
|
this.route.queryParams.pipe(first()).subscribe(async params => {
|
||||||
if (params.cipherId) {
|
if (params.cipherId) {
|
||||||
this.cipherId = params.cipherId;
|
this.cipherId = params.cipherId;
|
||||||
} else {
|
} else {
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
await this.init();
|
await this.init();
|
||||||
if (queryParamsSub != null) {
|
|
||||||
queryParamsSub.unsubscribe();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ import {
|
|||||||
Router,
|
Router,
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
|
|
||||||
|
import { first } from 'rxjs/operators';
|
||||||
|
|
||||||
import { CipherService } from 'jslib-common/abstractions/cipher.service';
|
import { CipherService } from 'jslib-common/abstractions/cipher.service';
|
||||||
import { CollectionService } from 'jslib-common/abstractions/collection.service';
|
import { CollectionService } from 'jslib-common/abstractions/collection.service';
|
||||||
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
||||||
@ -29,12 +31,9 @@ export class ShareComponent extends BaseShareComponent {
|
|||||||
this.onSharedCipher.subscribe(() => {
|
this.onSharedCipher.subscribe(() => {
|
||||||
this.router.navigate(['view-cipher', { cipherId: this.cipherId }]);
|
this.router.navigate(['view-cipher', { cipherId: this.cipherId }]);
|
||||||
});
|
});
|
||||||
const queryParamsSub = this.route.queryParams.subscribe(async params => {
|
this.route.queryParams.pipe(first()).subscribe(async params => {
|
||||||
this.cipherId = params.cipherId;
|
this.cipherId = params.cipherId;
|
||||||
await this.load();
|
await this.load();
|
||||||
if (queryParamsSub != null) {
|
|
||||||
queryParamsSub.unsubscribe();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ import {
|
|||||||
Router,
|
Router,
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
|
|
||||||
|
import { first } from 'rxjs/operators';
|
||||||
|
|
||||||
import { ApiService } from 'jslib-common/abstractions/api.service';
|
import { ApiService } from 'jslib-common/abstractions/api.service';
|
||||||
import { AuditService } from 'jslib-common/abstractions/audit.service';
|
import { AuditService } from 'jslib-common/abstractions/audit.service';
|
||||||
import { CipherService } from 'jslib-common/abstractions/cipher.service';
|
import { CipherService } from 'jslib-common/abstractions/cipher.service';
|
||||||
@ -65,7 +67,7 @@ export class ViewComponent extends BaseViewComponent {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.inPopout = this.popupUtilsService.inPopout(window);
|
this.inPopout = this.popupUtilsService.inPopout(window);
|
||||||
const queryParamsSub = this.route.queryParams.subscribe(async params => {
|
this.route.queryParams.pipe(first()).subscribe(async params => {
|
||||||
if (params.cipherId) {
|
if (params.cipherId) {
|
||||||
this.cipherId = params.cipherId;
|
this.cipherId = params.cipherId;
|
||||||
} else {
|
} else {
|
||||||
@ -73,9 +75,6 @@ export class ViewComponent extends BaseViewComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await this.load();
|
await this.load();
|
||||||
if (queryParamsSub != null) {
|
|
||||||
queryParamsSub.unsubscribe();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
|
Loading…
Reference in New Issue
Block a user