From c4d820a66624695b5b2632837c639da856513359 Mon Sep 17 00:00:00 2001 From: doubleface Date: Tue, 22 Oct 2024 16:52:39 +0200 Subject: [PATCH] fix: Do not try to save empty list of message --- src/index.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/index.js b/src/index.js index eefada2..4bf0f7a 100644 --- a/src/index.js +++ b/src/index.js @@ -225,11 +225,13 @@ class AmeliContentScript extends SuperContentScript { }) const messages = await this.fetchMessages() - await this.saveFiles(messages, { - context, - fileIdAttributes: ['vendorRef'], - contentType: 'application/pdf' - }) + if (messages) { + await this.saveFiles(messages, { + context, + fileIdAttributes: ['vendorRef'], + contentType: 'application/pdf' + }) + } const identity = await this.fetchIdentity() if (identity) { @@ -303,7 +305,7 @@ class AmeliContentScript extends SuperContentScript { if (await this.page.getByCss('.r_msg_aucun_message').isPresent()) { this.launcher.log('info', 'No message to fetch') - return + return false } const docs = await this.page.evaluate(function parseMessages() {