mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-02-16 00:19:32 -06:00
Only append when needed
This commit is contained in:
@@ -1399,11 +1399,24 @@ export class DocumentDetailComponent
|
||||
this.versionUploadError = null
|
||||
}
|
||||
|
||||
private getSelectedNonLatestVersionId(): number | null {
|
||||
const versions = this.document?.versions ?? []
|
||||
if (!versions.length || !this.selectedVersionId) {
|
||||
return null
|
||||
}
|
||||
const latestVersionId = Math.max(...versions.map((version) => version.id))
|
||||
return this.selectedVersionId === latestVersionId
|
||||
? null
|
||||
: this.selectedVersionId
|
||||
}
|
||||
|
||||
download(original: boolean = false) {
|
||||
this.downloading = true
|
||||
const selectedVersionId = this.getSelectedNonLatestVersionId()
|
||||
const downloadUrl = this.documentsService.getDownloadUrl(
|
||||
this.selectedVersionId || this.documentId,
|
||||
original
|
||||
this.documentId,
|
||||
original,
|
||||
selectedVersionId
|
||||
)
|
||||
this.http
|
||||
.get(downloadUrl, { observe: 'response', responseType: 'blob' })
|
||||
@@ -1835,9 +1848,11 @@ export class DocumentDetailComponent
|
||||
}
|
||||
|
||||
printDocument() {
|
||||
const selectedVersionId = this.getSelectedNonLatestVersionId()
|
||||
const printUrl = this.documentsService.getDownloadUrl(
|
||||
this.document.id,
|
||||
false
|
||||
false,
|
||||
selectedVersionId
|
||||
)
|
||||
this.http
|
||||
.get(printUrl, { responseType: 'blob' })
|
||||
|
||||
Reference in New Issue
Block a user