From ec9a38c2fe8fcaed3537b420d173517ae86a74fb Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 12 Nov 2019 15:02:52 -0700 Subject: [PATCH 1/3] Perform favicon updates twice in Chrome See diff for why this arcane magic is needed. Fixes https://github.com/vector-im/riot-web/issues/11347 --- src/vector/platform/VectorBasePlatform.js | 29 +++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/vector/platform/VectorBasePlatform.js b/src/vector/platform/VectorBasePlatform.js index f24031f732..e60da1448d 100644 --- a/src/vector/platform/VectorBasePlatform.js +++ b/src/vector/platform/VectorBasePlatform.js @@ -85,10 +85,31 @@ export default class VectorBasePlatform extends BasePlatform { bgColor = "#f00"; } - this.favicon.badge(notif, { - bgColor: bgColor, - }); - } catch (e) { + const doUpdate = () => { + this.favicon.badge(notif, { + bgColor: bgColor, + }); + }; + + doUpdate(); + + // HACK: Workaround for Chrome 78+ and dependency incompatibility. + // The library we use doesn't appear to work in Chrome 78, likely due to their + // changes surrounding tab behaviour. Tabs went through a bit of a redesign and + // restructuring in Chrome 78, so it's not terribly surprising that the library + // doesn't work correctly. The library we use hasn't been updated in years and + // does not look easy to fix/fork ourselves - we might as well write our own that + // doesn't include animation/webcam/etc support. However, that's a bit difficult + // so for now we'll just trigger the update twice. + // + // Note that trying to reproduce the problem in isolation doesn't seem to work: + // see https://gist.github.com/turt2live/5ab87919918adbfd7cfb8f1ad10f2409 for + // an example (you'll need your own web server to host that). + if (!!window.chrome) { + doUpdate(); + } + } + catch (e) { console.warn(`Failed to set badge count: ${e.message}`); } } From e84861f77027d20e035c49a444553538dd4738a0 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 12 Nov 2019 15:04:56 -0700 Subject: [PATCH 2/3] Apparently our eslint rules are different in different layers --- src/vector/platform/VectorBasePlatform.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vector/platform/VectorBasePlatform.js b/src/vector/platform/VectorBasePlatform.js index e60da1448d..6b01e05e56 100644 --- a/src/vector/platform/VectorBasePlatform.js +++ b/src/vector/platform/VectorBasePlatform.js @@ -105,7 +105,7 @@ export default class VectorBasePlatform extends BasePlatform { // Note that trying to reproduce the problem in isolation doesn't seem to work: // see https://gist.github.com/turt2live/5ab87919918adbfd7cfb8f1ad10f2409 for // an example (you'll need your own web server to host that). - if (!!window.chrome) { + if (window.chrome) { doUpdate(); } } From 71fb2e04a9923f68f3b158fabe7328f656a7ec41 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 12 Nov 2019 15:14:11 -0700 Subject: [PATCH 3/3] fix catch block indentation --- src/vector/platform/VectorBasePlatform.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/vector/platform/VectorBasePlatform.js b/src/vector/platform/VectorBasePlatform.js index 6b01e05e56..32b4382060 100644 --- a/src/vector/platform/VectorBasePlatform.js +++ b/src/vector/platform/VectorBasePlatform.js @@ -108,8 +108,7 @@ export default class VectorBasePlatform extends BasePlatform { if (window.chrome) { doUpdate(); } - } - catch (e) { + } catch (e) { console.warn(`Failed to set badge count: ${e.message}`); } }