From 58de839621b63b7dd3137abe822bfd893e135b88 Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 31 May 2018 22:32:29 +0200 Subject: [PATCH 1/2] Fix Tinter.setTheme to not fire using Firefox This if checks if we got a Firefox using a variable that is undefined everywhere except in Firefox. In Firefox because of how it renders the DOM ensure that css is always loaded before it loads/runs the js code. Therefor onload 1. never triggers and 2. we can just call setTheme. --- src/vector/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/vector/index.js b/src/vector/index.js index 14e181d9..0aab9060 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -313,9 +313,13 @@ async function loadApp() { // FIXME: we should probably block loading the app or even // showing a spinner until the theme is loaded, to avoid // flashes of unstyled content. - a.onload = () => { + if (typeof InstallTrigger !== 'undefined') { Tinter.setTheme(theme); - }; + } else { + a.onload = () => { + Tinter.setTheme(theme); + }; + } } else { // Firefox requires this to not be done via `setAttribute` // or via HTML. From 5b32ecb719b9223eb6d2459b75443c5ce10488d9 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 24 Jul 2018 13:38:49 +0200 Subject: [PATCH 2/2] [Tinter.setTheme fix] add missing comment and move old to correct position --- src/vector/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/vector/index.js b/src/vector/index.js index 0aab9060..67c69eb7 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -310,12 +310,19 @@ async function loadApp() { // in case the Tinter.tint() in MatrixChat fires before the // CSS has actually loaded (which in practice happens)... - // FIXME: we should probably block loading the app or even - // showing a spinner until the theme is loaded, to avoid - // flashes of unstyled content. + // This if fixes Tinter.setTheme to not fire on Firefox + // in case it is the first time loading Riot. + // `InstallTrigger` is a Object which only exists on Firefox + // (it is used for their Plugins) and can be used as a + // feature check. + // Firefox loads css always before js. This is why we dont use + // onload or it's EventListener as thoose will never trigger. if (typeof InstallTrigger !== 'undefined') { Tinter.setTheme(theme); } else { + // FIXME: we should probably block loading the app or even + // showing a spinner until the theme is loaded, to avoid + // flashes of unstyled content. a.onload = () => { Tinter.setTheme(theme); };