Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

refactor(frontend:files): introduce `openedFile` for cleaner dialog state management

johaven4b6c5b7a4694
diff --git a/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.ts b/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.ts
index af96774c..52785751 100644
--- a/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.ts
+++ b/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.ts
@@ -26,11 +26,13 @@ export class FilesViewerDialogComponent implements OnInit, OnDestroy {
@Input({ required: true }) shortMime: string
protected currentHeight: number
protected directoryImages = computed(() => this.directoryFiles.filter((file) => file.isImage))
+ private openedFile: { id: string | number; name: string; mimeUrl: string }
private readonly layout = inject(LayoutService)
private readonly subscription: Subscription = this.layout.resizeEvent.subscribe(() => this.onResize())
private readonly offsetTop = 42
ngOnInit() {
+ this.openedFile = { id: this.currentFile.id, name: this.currentFile.name, mimeUrl: this.currentFile.mimeUrl }
this.onResize()
}
@@ -39,11 +41,11 @@ export class FilesViewerDialogComponent implements OnInit, OnDestroy {
}
onClose() {
- this.layout.closeDialog(null, this.currentFile.id)
+ this.layout.closeDialog(null, this.openedFile.id)
}
onMinimize() {
- this.layout.minimizeDialog(this.currentFile.id, { name: this.currentFile.name, mimeUrl: this.currentFile.mimeUrl })
+ this.layout.minimizeDialog(this.openedFile.id, { name: this.openedFile.name, mimeUrl: this.openedFile.mimeUrl })
}
private onResize() {
diff --git a/frontend/src/app/applications/files/services/files.service.ts b/frontend/src/app/applications/files/services/files.service.ts
index 0f3e9388..0a0d0feb 100644
--- a/frontend/src/app/applications/files/services/files.service.ts
+++ b/frontend/src/app/applications/files/services/files.service.ts
@@ -232,12 +232,12 @@ export class FilesService {
try {
shortMime = await this.viewerHook(mode, currentFile)
} catch {
- // OnlyOffice not enabled, falling back to download
+ // OnlyOffice isn't enabled, falling back to download
this.download(currentFile)
return
}
this.layout.openDialog(FilesViewerDialogComponent, 'full', {
- id: currentFile.id,
+ id: currentFile.id, // only used to manage the modal
initialState: {
currentFile: currentFile,
directoryFiles: directoryFiles,