From fd0a41cfaf05c9703798e3068f18cff7daf4af78 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Fri, 28 Oct 2022 09:58:04 +0200 Subject: [PATCH] CLeanup Nextcloud javascript code --- plugins/nextcloud/js/composer.js | 4 +-- plugins/nextcloud/js/message.js | 41 +++++++++++++---------------- plugins/nextcloud/js/messagelist.js | 6 ++--- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/plugins/nextcloud/js/composer.js b/plugins/nextcloud/js/composer.js index f82c43cf8..45068cac5 100644 --- a/plugins/nextcloud/js/composer.js +++ b/plugins/nextcloud/js/composer.js @@ -43,8 +43,8 @@ let template = document.getElementById('PopupsCompose'); const uploadBtn = template.content.querySelector('#composeUploadButton'); if (uploadBtn) { - uploadBtn.after(Element.fromHTML('◦◯◦')); + uploadBtn.after(Element.fromHTML(`◦◯◦`)); } /** diff --git a/plugins/nextcloud/js/message.js b/plugins/nextcloud/js/message.js index 3d5eb8be9..2652a91c8 100644 --- a/plugins/nextcloud/js/message.js +++ b/plugins/nextcloud/js/message.js @@ -69,18 +69,12 @@ view.nextcloudSaveICS = () => { let attachment = view.nextcloudICS(); - attachment && rl.nextcloud.selectCalendar().then(href => { - 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)); - } - }); + attachment && rl.nextcloud.selectCalendar() + .then(href => + href && rl.fetch(attachment.linkDownload()) + .then(response => (response.status < 400) ? response.text() : Promise.reject(new Error({ response }))) + .then(text => rl.nextcloud.calendarPut(href, text)) + ); } } }); @@ -89,26 +83,27 @@ const attachmentsControls = template.content.querySelector('.attachmentsControls'); if (attachmentsControls) { - attachmentsControls.append(Element.fromHTML('' - + '✖' - + '💾' - + '' - + '')); + attachmentsControls.append(Element.fromHTML(` + ✖ + 💾 + + `)); // https://github.com/nextcloud/calendar/issues/4684 let cfg = rl.settings.get('Nextcloud'); if (cfg.CalDAV) { - attachmentsControls.append(Element.fromHTML('' - + '' - + '')); + attachmentsControls.append(Element.fromHTML(` + + `)); } } const msgMenu = template.content.querySelector('#more-view-dropdown-id + menu'); if (msgMenu) { - msgMenu.append(Element.fromHTML('