Skip to content

Commit ec9a38c

Browse files
committed
Perform favicon updates twice in Chrome
See diff for why this arcane magic is needed. Fixes element-hq#11347
1 parent c6f6263 commit ec9a38c

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/vector/platform/VectorBasePlatform.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,31 @@ export default class VectorBasePlatform extends BasePlatform {
8585
bgColor = "#f00";
8686
}
8787

88-
this.favicon.badge(notif, {
89-
bgColor: bgColor,
90-
});
91-
} catch (e) {
88+
const doUpdate = () => {
89+
this.favicon.badge(notif, {
90+
bgColor: bgColor,
91+
});
92+
};
93+
94+
doUpdate();
95+
96+
// HACK: Workaround for Chrome 78+ and dependency incompatibility.
97+
// The library we use doesn't appear to work in Chrome 78, likely due to their
98+
// changes surrounding tab behaviour. Tabs went through a bit of a redesign and
99+
// restructuring in Chrome 78, so it's not terribly surprising that the library
100+
// doesn't work correctly. The library we use hasn't been updated in years and
101+
// does not look easy to fix/fork ourselves - we might as well write our own that
102+
// doesn't include animation/webcam/etc support. However, that's a bit difficult
103+
// so for now we'll just trigger the update twice.
104+
//
105+
// Note that trying to reproduce the problem in isolation doesn't seem to work:
106+
// see https://gist.github.com/turt2live/5ab87919918adbfd7cfb8f1ad10f2409 for
107+
// an example (you'll need your own web server to host that).
108+
if (!!window.chrome) {
109+
doUpdate();
110+
}
111+
}
112+
catch (e) {
92113
console.warn(`Failed to set badge count: ${e.message}`);
93114
}
94115
}

0 commit comments

Comments
 (0)