From e9b50b7682946ad4a5ff964d51a138ed08f6700a Mon Sep 17 00:00:00 2001 From: Ashesh Vidyut Date: Fri, 22 Mar 2019 03:52:16 +0530 Subject: [PATCH] query selector fix + revert favicon in case of cancel and complete Co-authored-by: timvisee --- app/controller.js | 3 +++ app/ui/faviconProgressbar.js | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controller.js b/app/controller.js index 6482bc1c..c7c0769c 100644 --- a/app/controller.js +++ b/app/controller.js @@ -86,6 +86,7 @@ export default function(state, emitter) { emitter.on('cancel', () => { state.transfer.cancel(); + faviconProgressbar.updateFavicon(0); }); emitter.on('addFiles', async ({ files }) => { @@ -164,6 +165,7 @@ export default function(state, emitter) { state.storage.totalUploads += 1; const duration = Date.now() - start; metrics.completedUpload(archive, duration); + faviconProgressbar.updateFavicon(0); state.storage.addFile(ownedFile); // TODO integrate password into /upload request @@ -267,6 +269,7 @@ export default function(state, emitter) { duration, password_protected: file.requiresPassword }); + faviconProgressbar.updateFavicon(0); } catch (err) { if (err.message === '0') { // download cancelled diff --git a/app/ui/faviconProgressbar.js b/app/ui/faviconProgressbar.js index 04909daf..7967f5a3 100644 --- a/app/ui/faviconProgressbar.js +++ b/app/ui/faviconProgressbar.js @@ -28,16 +28,14 @@ function drawNewFavicon(progressRatio) { module.exports.updateFavicon = function(progressRatio) { if (platform() === 'web') { - const link = document.querySelector("link[rel*='icon']"); + const link = document.querySelector("link[rel='icon'][sizes='32x32']"); const progress = progressRatio * 100; if (progress === 0 || progress === 100) { link.type = 'image/png'; link.href = assets.get('favicon-32x32.png'); - document.getElementsByTagName('head')[0].appendChild(link); return; } link.href = drawNewFavicon(progressRatio); - document.getElementsByTagName('head')[0].appendChild(link); } };