Skip to content

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

refactor(frontend:files): use optional chaining (language?.name) to avoid null errors

johavenc5900c801d83
diff --git a/frontend/src/app/applications/files/components/viewers/files-viewer-text.component.ts b/frontend/src/app/applications/files/components/viewers/files-viewer-text.component.ts
index 079982b0..a1a21201 100644
--- a/frontend/src/app/applications/files/components/viewers/files-viewer-text.component.ts
+++ b/frontend/src/app/applications/files/components/viewers/files-viewer-text.component.ts
@@ -45,7 +45,7 @@ export class FilesViewerTextComponent implements OnInit, OnDestroy {
ngOnInit() {
const language: LanguageDescription = LanguageDescription.matchFilename(languages, this.file.name)
if (language?.name || this.file.size <= this.maxSize) {
- this.currentLanguage = language.name
+ this.currentLanguage = language?.name
this.http.get(this.file.dataUrl, { responseType: 'text' }).subscribe((data: string) => (this.content = data))
} else {
this.content = this.layout.translateString('This file contains binary data that can not be read')