Skip to content

Commit 47ade14

Browse files
authored
Merge pull request element-hq#6831 from MTRNord/patch-8
Fix Tinter.setTheme to not fire using Firefox
2 parents df1eb9f + 5b32ecb commit 47ade14

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/vector/index.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,23 @@ async function loadApp() {
289289
// in case the Tinter.tint() in MatrixChat fires before the
290290
// CSS has actually loaded (which in practice happens)...
291291

292-
// FIXME: we should probably block loading the app or even
293-
// showing a spinner until the theme is loaded, to avoid
294-
// flashes of unstyled content.
295-
a.onload = () => {
292+
// This if fixes Tinter.setTheme to not fire on Firefox
293+
// in case it is the first time loading Riot.
294+
// `InstallTrigger` is a Object which only exists on Firefox
295+
// (it is used for their Plugins) and can be used as a
296+
// feature check.
297+
// Firefox loads css always before js. This is why we dont use
298+
// onload or it's EventListener as thoose will never trigger.
299+
if (typeof InstallTrigger !== 'undefined') {
296300
Tinter.setTheme(theme);
297-
};
301+
} else {
302+
// FIXME: we should probably block loading the app or even
303+
// showing a spinner until the theme is loaded, to avoid
304+
// flashes of unstyled content.
305+
a.onload = () => {
306+
Tinter.setTheme(theme);
307+
};
308+
}
298309
} else {
299310
// Firefox requires this to not be done via `setAttribute`
300311
// or via HTML.

0 commit comments

Comments
 (0)