Skip to content

Commit

Permalink
fix: Paper creation from the Cozy
Browse files Browse the repository at this point in the history
“File” doesn't have exactly the same attributes
between Chrome and Firefox!
In this case, we were using the `lastModifiedDate` attribute,
but it doesn't exist on Firefox.
  • Loading branch information
Merkur39 committed Oct 24, 2024
1 parent e0779e2 commit f3ab34f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/helpers/createPdfAndSave.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ export const createPdfAndSave = async ({
// Created first document of PDFDocument
let pdfDoc = isAlreadyPDFDoc ? data[0].file : await PDFDocument.create()

// On Firefox, the lastModifiedDate doesn't exist, prefer the lastModified attribute
const datetime = isAlreadyPDFDoc
? pdfDoc.lastModifiedDate.toISOString()
? new Date(pdfDoc.lastModified).toISOString()
: pdfDoc.getCreationDate()

// If present, we wish to keep the value in the metadata as a priority (e.g. foreign driver's license).
Expand Down
1 change: 0 additions & 1 deletion src/helpers/createPdfAndSave.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ describe('createAndSavePdf', () => {
const filePDF = new File(['bob'], 'bob.pdf', {
type: 'application/pdf'
})
filePDF.lastModifiedDate = new Date()
const fileJPG = new File(['bob'], 'bob.jpg', {
type: 'image/jpg'
})
Expand Down

0 comments on commit f3ab34f

Please sign in to comment.