From a1cafb1d0c39750c54a73eea997a6a716b149e3d Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Fri, 28 Oct 2022 09:45:11 +0200 Subject: [PATCH] Bugfix: when Nextcloud calendar is cancelled, don't try to save #569 --- plugins/nextcloud/js/message.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/plugins/nextcloud/js/message.js b/plugins/nextcloud/js/message.js index 4a46fd0c7..3d5eb8be9 100644 --- a/plugins/nextcloud/js/message.js +++ b/plugins/nextcloud/js/message.js @@ -70,15 +70,16 @@ view.nextcloudSaveICS = () => { let attachment = view.nextcloudICS(); attachment && rl.nextcloud.selectCalendar().then(href => { - console.dir({href: href}); - fetch(attachment.linkDownload(), { - mode: 'same-origin', - cache: 'no-cache', - redirect: 'error', - credentials: 'same-origin' - }) - .then(response => (response.status < 400) ? response.text() : Promise.reject(new Error({ response }))) - .then(text => rl.nextcloud.calendarPut(href, text)); + if (href) { + fetch(attachment.linkDownload(), { + mode: 'same-origin', + cache: 'no-cache', + redirect: 'error', + credentials: 'same-origin' + }) + .then(response => (response.status < 400) ? response.text() : Promise.reject(new Error({ response }))) + .then(text => rl.nextcloud.calendarPut(href, text)); + } }); } }