in client/src/pages/translate/translate.ts [63:93]
ngOnInit() {
this.analyticsService.logPageView(this.router.url, 'Translate');
this.defaultSelectedWordIndex = history.state.selectedWordIndex !== undefined ? history.state.selectedWordIndex : -1;
const image: Blob | undefined = history.state.image;
const imageURL: string | undefined = history.state.imageURL;
const words: string[] | undefined = history.state.words || this.config.debugWords;
let loadingPopUp: MatDialogRef<any> | undefined = this.sessionService.currentSession.currentModal;
if (!loadingPopUp) {
loadingPopUp = this.dialog.open(LoadingPopUpComponent, { closeOnNavigation: false, disableClose: true, panelClass: 'loading-popup' });
this.sessionService.currentSession.currentModal = loadingPopUp;
loadingPopUp.beforeClosed().subscribe({
next: () => this.sessionService.currentSession.currentModal = null
});
}
this.initImageTranslations(image, imageURL, words).then(
() => {
loadingPopUp?.close();
},
ex => {
loadingPopUp?.close();
if (ex instanceof WordsNotFoundError) {
this.router.navigateByUrl(AppRoutes.CaptionImage, { state: { image } });
} else {
loadCapturePageURL().then(
url => this.router.navigateByUrl(url, { replaceUrl: true }),
() => this.router.navigateByUrl(AppRoutes.CaptureImage, { replaceUrl: true }),
);
}
}
);
}