Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ngOnInit() {
this.log.i('Loading component booted!');
/* Daemon download */
this.updater.status.asObservable().subscribe(status => {
this.log.d(`updating statusMessage: `, status);
this.loadingMessage = status;
});
// we wait until the multiwallet has retrieved the wallets
this.multi.list.pipe(take(1)).subscribe(wallets => {
// we also pass through the loading screen to switch wallets
// check if a wallet was specified
this.route.queryParamMap.pipe(take(1)).subscribe((params: ParamMap) => {
this.log.d('loading params', params);
// we can only pass strings through
const switching = params.get('wallet');
if (switching !== null && switching !== undefined) {
// one was specified
this.rpc.wallet = switching;
}
this.con.performCheck();
// kick off the connection checker
// only after we have a wallet or default
this.con
private setupLayout(pageState?: DotPageRenderState): void {
if (pageState) {
this.pageState = pageState;
}
this.templateContainersCacheService.set(this.pageState.containers);
this.initForm();
this.saveAsTemplateHandleChange(false);
this.dotThemesService
.get(this.form.get('themeId').value)
.pipe(take(1))
.subscribe(
(theme: DotTheme) => {
this.currentTheme = theme;
},
(error: ResponseView) => this.errorHandler(error)
);
// Emit event to redraw the grid when the sidebar change
this.form
.get('layout.sidebar')
.valueChanges.pipe(takeUntil(this.destroy$))
.subscribe(() => {
this.dotEventsService.notify('layout-sidebar-change');
});
}
private _mapHttp$(paramsIN: HttpRequest | any): Observable {
const loginObs = this._session$.pipe(
take(1),
concatMap((session) => {
const isRefreshNecessary = !session.accessToken || this._isTokenExpired(session);
if (isRefreshNecessary) {
return this.login(true);
} else {
return of(true);
}
})
);
return from(loginObs)
.pipe(
concatMap(() => {
const p: any = {
...paramsIN,
headers: {
if (
!this.isCreated(saveForLaterState.value.content) &&
!saveForLaterState.loading
) {
this.store.dispatch(
new CartActions.CreateSaveForLater({
userId: this.saveForLaterData.userId,
cartId: this.saveForLaterData.cartId,
})
);
}
}),
filter(saveForLaterState =>
this.isCreated(saveForLaterState.value.content)
),
take(1)
)
.subscribe(_ => {
this.store.dispatch(
new CartActions.CartAddEntry({
userId: this.saveForLaterData.userId,
cartId: this.saveForLaterData.cartId,
productCode: productCode,
quantity: quantity,
isSaveForLater: true,
})
);
});
}
constructor(public translate: TranslateService, activatedRoute: ActivatedRoute) {
activatedRoute.data.pipe(take(1)).subscribe(params => {
const { type } = params;
this.type = type;
});
}
}
getHeadMessages(executionId, partitionSize) {
return this.db
.executionMessageRef(executionId)
.orderByChild('index')
.startAt(0)
.limitToFirst(partitionSize)
.childAdded()
.pipe(take(partitionSize), snapshotToValue);
}
loadProposals(): void {
this.proposalsService
.list(this.lastUpdatedTimeStamp, '*')
.pipe(take(1))
.subscribe((proposals: Proposal[]) => {
let tempCount = 0;
if (proposals.length) {
for (let idx = proposals.length - 1; idx >= 0; idx--) {
const proposal: Proposal = proposals[idx];
if (proposal && (+proposal.createdAt > this.lastUpdatedTimeStamp)) {
tempCount++;
}
}
if (tempCount > 0) {
let needUpdating = false;
for (let idx = proposals.length - tempCount; idx < proposals.length; idx++) {
const proposal: Proposal = proposals[idx];
if (proposal && +proposal.createdAt > this.notifcationTimestamp) {
needUpdating = true;
this.notifyNewProposal(proposal);
requestPage(options: DotPageRenderOptions): Observable {
return this.dotPageRenderService.get(options).pipe(
catchError((err: ResponseView) => this.handleSetPageStateFailed(err)),
take(1),
map((page: DotPageRender.Parameters) => {
if (page) {
const pageState = new DotPageRenderState(this.getCurrentUser(), page);
this.setCurrentState(pageState);
return pageState;
}
return this.currentState;
})
);
}
private loadOptions(): void {
this.dotLanguagesService
.get()
.pipe(take(1))
.subscribe(
(languages: DotLanguage[]) => {
this.options = this.decorateLabels(languages);
this.disabled = this.options.length === 0;
},
() => {
this.disabled = true;
}
);
}
}
.pipe(switchMap((response: LoginResponse) => {
const newAuthData: AuthData = response;
this.authData$.next(newAuthData);
localStorage.setItem(LocalstoragePaths.authPath, JSON.stringify(newAuthData));
const userData$ = this.getUserData();
userData$.pipe(filter(v => !!v), take(1)).subscribe(() => {
this.websocket.setBearer(newAuthData.authToken);
});
return userData$;
}));
}