protected loadImageDescriptions()

in client/src/pages/capture/capture.ts [37:68]


  protected loadImageDescriptions(image: Blob, loadingPopUp: MatDialogRef<CapturePopUpComponent>) {
    this.imageRecognitionService.loadDescriptions(image).then(
      (descriptions) => {
        if (descriptions.length > 0) {
          this.router.navigateByUrl(AppRoutes.Translate, {
            state: {
              image, imageURL: URL.createObjectURL(image), words: descriptions.map(d => d.description)
            }
          }).then(
            (success) => {
              if (!success) {
                loadingPopUp.close();
              }
            },
            () => loadingPopUp.close()
          );
        } else {
          this.router.navigateByUrl(AppRoutes.CaptionImage, { state: { image, imageURL: URL.createObjectURL(image) } }).finally(
            () => loadingPopUp.close()
          );
        }
      },
      (err) => {
        logger.warn('Error loading image descriptions', err);
        loadingPopUp.close();
        const errorTitle = this.i18n.getTranslation('imageRecognitionErrorTitle') || 'Unable to connect';
        const errorMessage = this.i18n.getTranslation('imageRecognitionErrorMessage') || 'Please check network connection';
        this.dialog.open(ErrorPopUpComponent, { data: { message: errorMessage, title: errorTitle } });
        this.router.navigateByUrl(AppRoutes.CaptionImage, { state: { image, imageURL: URL.createObjectURL(image) } });
      }
    );
  }