From 1fd7ac30e444226dcfc9cdc6cab37616c38af633 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 14 Nov 2017 16:04:11 +0000 Subject: [PATCH] turns out i made up the .complete property on link elements --- src/Tinter.js | 2 +- src/components/structures/MatrixChat.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Tinter.js b/src/Tinter.js index 1b2416762f..c926ada591 100644 --- a/src/Tinter.js +++ b/src/Tinter.js @@ -217,7 +217,7 @@ class Tinter { // cache our fixups if (this.cssFixups[this.theme]) return; - if (DEBUG) console.trace("calcCssFixups start for " + this.theme + " (checking " + + if (DEBUG) console.debug("calcCssFixups start for " + this.theme + " (checking " + document.styleSheets.length + " stylesheets)"); diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index f2df1df851..26eed952d8 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -931,7 +931,17 @@ module.exports = React.createClass({ Tinter.tint(colors[0], colors[1]); }; - if (styleElements[theme].complete) { + let cssLoaded = false; + + for (let i = 0; i < document.styleSheets.length; i++) { + const ss = document.styleSheets[i]; + if (ss && ss.href === styleElements[theme].href) { + cssLoaded = true; + break; + } + } + + if (cssLoaded) { switchTheme(); } else { styleElements[theme].onload = () => {