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,
tags: [41, 42, 43],
content: 'text content',
added: new Date('May 4, 2014 03:24:00'),
created: new Date('May 4, 2014 03:24:00'),
modified: 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').toISOString(),
modified: new Date('May 4, 2014 03:24:00').toISOString(),
archive_serial_number: null,
original_file_name: 'file.pdf',
owner: null,
@@ -392,7 +392,7 @@ describe('DocumentDetailComponent', () => {
jest.spyOn(documentService, 'get').mockReturnValue(
of({
...doc,
modified: new Date('2024-01-02T00:00:00Z'),
modified: '2024-01-02T00:00:00Z',
duplicate_documents: updatedDuplicates,
})
)
@@ -1214,7 +1214,7 @@ describe('DocumentDetailComponent', () => {
})
// simulate a document being modified elsewhere and db updated
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
.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
const modal = this.modalService.open(ConfirmDialogComponent, {
@@ -497,12 +497,6 @@ export class DocumentDetailComponent
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 {
this.closeIncomingUpdateModal()
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,
// we assume this update is from our own save and dont notify
const incomingModified = this.getModifiedRawValue(data.modified)
const incomingModified = data.modified
if (
incomingModified &&
this.lastLocalSaveModified &&
@@ -1089,9 +1083,7 @@ export class DocumentDetailComponent
.subscribe({
next: (docValues) => {
this.closeIncomingUpdateModal()
this.lastLocalSaveModified = this.getModifiedRawValue(
docValues.modified
)
this.lastLocalSaveModified = docValues.modified ?? null
// in case data changed while saving eg removing inbox_tags
this.documentForm.patchValue(docValues)
const newValues = Object.assign({}, this.documentForm.value)

View File

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