Merge pull request #852 from paperless-ngx/fix-818

Fix: Older dates do not display on frontend
This commit is contained in:
shamoon
2022-05-01 13:36:55 -07:00
committed by GitHub
3 changed files with 14 additions and 10 deletions

View File

@@ -34,6 +34,7 @@ import {
} from 'rxjs/operators'
import { PaperlessDocumentSuggestions } from 'src/app/data/paperless-document-suggestions'
import { FILTER_FULLTEXT_MORELIKE } from 'src/app/data/filter-rule-type'
import { normalizeDateStr } from 'src/app/utils/date'
@Component({
selector: 'app-document-detail',
@@ -146,7 +147,7 @@ export class DocumentDetailComponent
.pipe(takeUntil(this.unsubscribeNotifier))
.subscribe((changes) => {
if (this.ogDate) {
let newDate = new Date(changes['created'])
let newDate = new Date(normalizeDateStr(changes['created']))
newDate.setHours(
this.ogDate.getHours(),
this.ogDate.getMinutes(),
@@ -154,7 +155,7 @@ export class DocumentDetailComponent
this.ogDate.getMilliseconds()
)
this.documentForm.patchValue(
{ created: this.formatDate(newDate) },
{ created: newDate.toISOString() },
{ emitEvent: false }
)
}
@@ -199,22 +200,22 @@ export class DocumentDetailComponent
this.updateComponent(doc)
}
this.ogDate = new Date(doc.created)
this.ogDate = new Date(normalizeDateStr(doc.created.toString()))
// Initialize dirtyCheck
this.store = new BehaviorSubject({
title: doc.title,
content: doc.content,
created: this.formatDate(this.ogDate),
created: this.ogDate.toISOString(),
correspondent: doc.correspondent,
document_type: doc.document_type,
archive_serial_number: doc.archive_serial_number,
tags: [...doc.tags],
})
// ensure we're always starting with 24-char ISO8601 string
// start with ISO8601 string
this.documentForm.patchValue(
{ created: this.formatDate(this.ogDate) },
{ created: this.ogDate.toISOString() },
{ emitEvent: false }
)
@@ -486,8 +487,4 @@ export class DocumentDetailComponent
this.password = (event.target as HTMLInputElement).value
}
}
formatDate(date: Date): string {
return date.toISOString().split('.')[0] + 'Z'
}
}