Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
fix(frontend:files): update file metadata timestamps on save and align OnlyOffice state change handlers
johavendb768e14452f
diff --git a/backend/src/applications/files/interfaces/only-office-config.interface.ts b/backend/src/applications/files/interfaces/only-office-config.interface.tsindex fa7ad4af..87823497 100644--- a/backend/src/applications/files/interfaces/only-office-config.interface.ts+++ b/backend/src/applications/files/interfaces/only-office-config.interface.ts@@ -165,7 +165,7 @@ export interface OnlyOfficeConfig {onAppReady?: (event: object) => voidonCollaborativeChanges?: (event: object) => voidonDocumentReady?: (event: object) => void- onDocumentStateChange?: (event: object) => void+ onDocumentStateChange?: (event: { data: boolean }) => voidonDownloadAs?: (event: object) => voidonError?: (event: object) => voidonInfo?: (event: object) => void@@ -191,7 +191,7 @@ export interface OnlyOfficeConfig {onRequestSelectSpreadsheet?: (event: object) => voidonRequestSendNotify?: (event: object) => voidonRequestSharingSettings?: (event: object) => void- onRequestStartFilling: (event: object) => void+ onRequestStartFilling?: (event: object) => voidonRequestUsers?: (event: object) => voidonSubmit?: (event: object) => voidonWarning?: (event: object) => voiddiff --git a/frontend/src/app/applications/files/components/utils/only-office.component.ts b/frontend/src/app/applications/files/components/utils/only-office.component.tsindex a2e02068..c039233b 100644--- a/frontend/src/app/applications/files/components/utils/only-office.component.ts+++ b/frontend/src/app/applications/files/components/utils/only-office.component.ts@@ -17,6 +17,7 @@ export class OnlyOfficeComponent implements OnInit, OnChanges, OnDestroy {@Input() documentServerUrl: string@Input() config: OnlyOfficeConfig@Output() loadError = new EventEmitter<string>()+ @Output() wasSaved = new EventEmitter<string>()private isFirstOnChanges = truengOnInit(): void {@@ -51,6 +52,7 @@ export class OnlyOfficeComponent implements OnInit, OnChanges, OnDestroy {if (window?.DocEditor?.instances[this.id]) {window.DocEditor.instances[this.id].destroyEditor()window.DocEditor.instances[this.id] = undefined+ delete window.DocEditor.instances[this.id]}}@@ -70,6 +72,7 @@ export class OnlyOfficeComponent implements OnInit, OnChanges, OnDestroy {}const config: OnlyOfficeConfig = JSON.parse(JSON.stringify(this.config))+ config.events = { onDocumentStateChange: (e: { data: boolean }) => (e.data ? this.wasSaved.emit() : null) }window.DocEditor.instances[this.id] = window.DocsAPI.DocEditor(this.id, config)} catch (err) {console.error(err)diff --git a/frontend/src/app/applications/files/components/viewers/files-viewer-document.component.ts b/frontend/src/app/applications/files/components/viewers/files-viewer-document.component.tsindex f101b834..2537b9ed 100644--- a/frontend/src/app/applications/files/components/viewers/files-viewer-document.component.ts+++ b/frontend/src/app/applications/files/components/viewers/files-viewer-document.component.ts@@ -35,6 +35,7 @@ import { OnlyOfficeComponent } from '../utils/only-office.component'[documentServerUrl]="documentConfig.documentServerUrl"[config]="documentConfig.config"(loadError)="loadError($event)"+ (wasSaved)="onSave()"></app-files-onlyoffice-document></div>}@@ -95,4 +96,8 @@ export class FilesViewerDocumentComponent implements OnInit, OnDestroy {this.layout.closeDialog()this.layout.sendNotification('error', 'Unable to open document', errorMessage)}++ onSave() {+ this.file.updateHTimeAgo()+ }}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.tsindex d8f0380f..a2d984ef 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@@ -203,6 +203,7 @@ export class FilesViewerTextComponent implements OnInit, OnDestroy {if (exit) {this.onClose().catch(console.error)}+ this.file().updateHTimeAgo()},error: (e: HttpErrorResponse) => {this.isSaving.set(false)diff --git a/frontend/src/app/applications/files/models/file.model.ts b/frontend/src/app/applications/files/models/file.model.tsindex 1a4ee84f..828922a6 100644--- a/frontend/src/app/applications/files/models/file.model.ts+++ b/frontend/src/app/applications/files/models/file.model.ts@@ -13,7 +13,7 @@ import {import type { FileLockProps, FileProps } from '@sync-in-server/backend/src/applications/files/interfaces/file-props.interface'import type { File } from '@sync-in-server/backend/src/applications/files/schemas/file.interface'import { SPACE_OPERATION } from '@sync-in-server/backend/src/applications/spaces/constants/spaces'-import { popFromObject } from '@sync-in-server/backend/src/common/shared'+import { currentTimeStamp, popFromObject } from '@sync-in-server/backend/src/common/shared'import type { Observable } from 'rxjs'import { convertBytesToText, getNewly } from '../../../common/utils/functions'import { dJs } from '../../../common/utils/time'@@ -92,8 +92,7 @@ export class FileModel implements File {Object.assign(this, props)this.path = `${basePath}/${this.path !== '.' ? `${this.path}/` : ''}${this.root?.alias || this.name}`this.mime = this.getMime(this.mime, inShare)- this.hTimeAgo = dJs(this.mtime).fromNow(true)- this.newly = getNewly(this.mtime)+ this.updateHTimeAgo(this.mtime)this.setMimeUrl()this.setHSize()this.setRoot(inShare)@@ -125,6 +124,12 @@ export class FileModel implements File {this.setMimeUrl()}+ updateHTimeAgo(mtime?: number) {+ mtime ??= currentTimeStamp(null, true)+ this.hTimeAgo = dJs(mtime).fromNow(true)+ this.newly = getNewly(mtime)+ }+private getType(inShare: boolean) {return this.isDir ? (inShare ? mimeDirectoryShare : mimeDirectory) : mimeFile}