Actually these are not Dates

This commit is contained in:
shamoon
2026-02-17 13:01:25 -08:00
parent 4b7549e4a6
commit d678725463
3 changed files with 12 additions and 20 deletions

View File

@@ -83,9 +83,9 @@ const doc: Document = {
storage_path: 31, storage_path: 31,
tags: [41, 42, 43], tags: [41, 42, 43],
content: 'text content', content: 'text content',
added: new Date('May 4, 2014 03:24:00'), added: new Date('May 4, 2014 03:24:00').toISOString(),
created: new Date('May 4, 2014 03:24:00'), created: new Date('May 4, 2014 03:24:00').toISOString(),
modified: new Date('May 4, 2014 03:24:00'), modified: new Date('May 4, 2014 03:24:00').toISOString(),
archive_serial_number: null, archive_serial_number: null,
original_file_name: 'file.pdf', original_file_name: 'file.pdf',
owner: null, owner: null,
@@ -392,7 +392,7 @@ describe('DocumentDetailComponent', () => {
jest.spyOn(documentService, 'get').mockReturnValue( jest.spyOn(documentService, 'get').mockReturnValue(
of({ of({
...doc, ...doc,
modified: new Date('2024-01-02T00:00:00Z'), modified: '2024-01-02T00:00:00Z',
duplicate_documents: updatedDuplicates, duplicate_documents: updatedDuplicates,
}) })
) )
@@ -1214,7 +1214,7 @@ describe('DocumentDetailComponent', () => {
}) })
// simulate a document being modified elsewhere and db updated // simulate a document being modified elsewhere and db updated
const remoteDoc = Object.assign({}, doc, { const remoteDoc = Object.assign({}, doc, {
modified: new Date(new Date(doc.modified).getTime() + 1000), modified: new Date(new Date(doc.modified).getTime() + 1000).toISOString(),
}) })
jest jest
.spyOn(activatedRoute, 'paramMap', 'get') .spyOn(activatedRoute, 'paramMap', 'get')

View File

@@ -449,7 +449,7 @@ export class DocumentDetailComponent
) )
} }
private showIncomingUpdateModal(modified?: string | Date): void { private showIncomingUpdateModal(modified?: string): void {
if (this.incomingUpdateModal) return if (this.incomingUpdateModal) return
const modal = this.modalService.open(ConfirmDialogComponent, { const modal = this.modalService.open(ConfirmDialogComponent, {
@@ -497,12 +497,6 @@ export class DocumentDetailComponent
this.handleIncomingDocumentUpdated(pendingUpdate) this.handleIncomingDocumentUpdated(pendingUpdate)
} }
private getModifiedRawValue(modified: string | Date): string | null {
if (!modified) return null
if (typeof modified === 'string') return modified
return modified.toISOString()
}
private loadDocument(documentId: number, forceRemote: boolean = false): void { private loadDocument(documentId: number, forceRemote: boolean = false): void {
this.closeIncomingUpdateModal() this.closeIncomingUpdateModal()
this.pendingIncomingUpdate = null this.pendingIncomingUpdate = null
@@ -613,7 +607,7 @@ export class DocumentDetailComponent
} }
// If modified timestamp of the incoming update is the same as the last local save, // If modified timestamp of the incoming update is the same as the last local save,
// we assume this update is from our own save and dont notify // we assume this update is from our own save and dont notify
const incomingModified = this.getModifiedRawValue(data.modified) const incomingModified = data.modified
if ( if (
incomingModified && incomingModified &&
this.lastLocalSaveModified && this.lastLocalSaveModified &&
@@ -1089,9 +1083,7 @@ export class DocumentDetailComponent
.subscribe({ .subscribe({
next: (docValues) => { next: (docValues) => {
this.closeIncomingUpdateModal() this.closeIncomingUpdateModal()
this.lastLocalSaveModified = this.getModifiedRawValue( this.lastLocalSaveModified = docValues.modified ?? null
docValues.modified
)
// in case data changed while saving eg removing inbox_tags // in case data changed while saving eg removing inbox_tags
this.documentForm.patchValue(docValues) this.documentForm.patchValue(docValues)
const newValues = Object.assign({}, this.documentForm.value) const newValues = Object.assign({}, this.documentForm.value)

View File

@@ -128,15 +128,15 @@ export interface Document extends ObjectWithPermissions {
checksum?: string checksum?: string
// UTC // UTC
created?: Date created?: string // ISO string
modified?: Date modified?: string // ISO string
added?: Date added?: string // ISO string
mime_type?: string mime_type?: string
deleted_at?: Date deleted_at?: string // ISO string
original_file_name?: string original_file_name?: string