handled deleted file when click on notification file link
This commit is contained in:
parent
717651f01c
commit
10b94cba3c
@ -29,7 +29,7 @@ const routes: Routes = [
|
||||
path: `:${DOSSIER_ID}/file/:${FILE_ID}`,
|
||||
canActivate: [CompositeRouteGuard],
|
||||
data: {
|
||||
routeGuards: [DossierFilesGuard, FilePreviewGuard],
|
||||
routeGuards: [DossierFilesGuard],
|
||||
breadcrumbs: [BreadcrumbTypes.archive, BreadcrumbTypes.dossier, BreadcrumbTypes.file],
|
||||
dossiersService: ARCHIVED_DOSSIERS_SERVICE,
|
||||
},
|
||||
|
||||
@ -22,7 +22,7 @@ const routes: Routes = [
|
||||
path: `:${DOSSIER_ID}/file/:${FILE_ID}`,
|
||||
canActivate: [CompositeRouteGuard],
|
||||
data: {
|
||||
routeGuards: [DossierFilesGuard, FilePreviewGuard],
|
||||
routeGuards: [DossierFilesGuard],
|
||||
breadcrumbs: [BreadcrumbTypes.main, BreadcrumbTypes.dossier, BreadcrumbTypes.file],
|
||||
dossiersService: ACTIVE_DOSSIERS_SERVICE,
|
||||
},
|
||||
|
||||
@ -202,7 +202,8 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
async ngOnAttach(previousRoute: ActivatedRouteSnapshot): Promise<boolean> {
|
||||
const file = await this.stateService.file;
|
||||
if (!file.canBeOpened) {
|
||||
return this._router.navigate([this._dossiersService.find(this.dossierId)?.routerLink]);
|
||||
this._navigateToDossier();
|
||||
return;
|
||||
}
|
||||
this._viewModeService.compareMode = false;
|
||||
this._viewModeService.switchToStandard();
|
||||
@ -214,18 +215,23 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
}
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
this.ready = false;
|
||||
this._loadingService.start();
|
||||
await this.userPreferenceService.saveLastOpenedFileForDossier(this.dossierId, this.fileId);
|
||||
this._subscribeToFileUpdates();
|
||||
|
||||
const file = await this.stateService.file;
|
||||
if (file?.analysisRequired && !file.excludedFromAutomaticAnalysis) {
|
||||
const reanalyzeFiles = this._reanalysisService.reanalyzeFilesForDossier([file], this.dossierId, { force: true });
|
||||
await firstValueFrom(reanalyzeFiles);
|
||||
}
|
||||
|
||||
this.displayPdfViewer = true;
|
||||
if (!file) {
|
||||
this._handleDeletedFile();
|
||||
} else {
|
||||
this.ready = false;
|
||||
this._loadingService.start();
|
||||
await this.userPreferenceService.saveLastOpenedFileForDossier(this.dossierId, this.fileId);
|
||||
this._subscribeToFileUpdates();
|
||||
|
||||
if (file?.analysisRequired && !file.excludedFromAutomaticAnalysis) {
|
||||
const reanalyzeFiles = this._reanalysisService.reanalyzeFilesForDossier([file], this.dossierId, { force: true });
|
||||
await firstValueFrom(reanalyzeFiles);
|
||||
}
|
||||
|
||||
this.displayPdfViewer = true;
|
||||
}
|
||||
}
|
||||
|
||||
async rebuildFilters() {
|
||||
@ -586,10 +592,10 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
.pipe(tap(() => this._handleDeletedDossier()))
|
||||
.subscribe();
|
||||
|
||||
this.addActiveScreenSubscription = this._filesMapService
|
||||
.watchDeleted$(this.fileId)
|
||||
.pipe(tap(() => this._handleDeletedFile()))
|
||||
.subscribe();
|
||||
// this.addActiveScreenSubscription = this._filesMapService
|
||||
// .watchDeleted$(this.fileId)
|
||||
// .pipe(tap(() => this._handleDeletedFile()))
|
||||
// .subscribe();
|
||||
|
||||
this.addActiveScreenSubscription = this._skippedService.hideSkipped$
|
||||
.pipe(tap(hideSkipped => this._handleIgnoreAnnotationsDrawing(hideSkipped)))
|
||||
@ -604,7 +610,13 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
|
||||
private _handleDeletedFile(): void {
|
||||
this._errorService.set(
|
||||
new CustomError(_('error.deleted-entity.file.label'), _('error.deleted-entity.file.action'), 'iqser:expand'),
|
||||
new CustomError(
|
||||
_('error.deleted-entity.file.label'),
|
||||
_('error.deleted-entity.file.action'),
|
||||
'iqser:expand',
|
||||
null,
|
||||
this._navigateToDossier.bind(this),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -677,4 +689,8 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
annotation['FillColor'] = color;
|
||||
});
|
||||
}
|
||||
|
||||
private _navigateToDossier() {
|
||||
this._router.navigate([this._dossiersService.find(this.dossierId)?.routerLink]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,12 +102,7 @@ export class FileDataService {
|
||||
async loadAnnotations() {
|
||||
const file = await this._state.file;
|
||||
|
||||
if (!file) {
|
||||
const dossier = await this._state.dossier;
|
||||
return this._router.navigate([dossier.routerLink]);
|
||||
}
|
||||
|
||||
if (file.isUnprocessed) {
|
||||
if (!file || file.isUnprocessed) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user