From ebcc65dc7eafa4ab0d45558464f1cce65de9fb6f Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 12 Oct 2018 13:52:58 -0600 Subject: [PATCH 1/2] Apply the user's tint once the MatrixClientPeg is moderately ready Any earlier and we risk getting NPEs from the peg not existing. Fixes https://github.com/vector-im/riot-web/issues/6424 --- src/MatrixClientPeg.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index f02c751a2c..3fca482aba 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -26,6 +26,7 @@ import EventTimelineSet from 'matrix-js-sdk/lib/models/event-timeline-set'; import createMatrixClient from './utils/createMatrixClient'; import SettingsStore from './settings/SettingsStore'; import MatrixActionCreators from './actions/MatrixActionCreators'; +import Tinter from "./Tinter"; interface MatrixClientCreds { homeserverUrl: string, @@ -128,6 +129,9 @@ class MatrixClientPeg { opts.lazyLoadMembers = true; } + const color_scheme = SettingsStore.getValue("roomColor"); + Tinter.tint(color_scheme.primary_color, color_scheme.secondary_color); + // Connect the matrix client to the dispatcher MatrixActionCreators.start(this.matrixClient); From 6323d78b0cfc5857fde1b72fa9831daa25cc360c Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 15 Oct 2018 14:41:00 -0600 Subject: [PATCH 2/2] Move tinter init to MatrixChat This is a much better place for it to live --- src/MatrixClientPeg.js | 4 ---- src/components/structures/MatrixChat.js | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index b524033b70..04b3b47e43 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -27,7 +27,6 @@ import createMatrixClient from './utils/createMatrixClient'; import SettingsStore from './settings/SettingsStore'; import MatrixActionCreators from './actions/MatrixActionCreators'; import {phasedRollOutExpiredForUser} from "./PhasedRollOut"; -import Tinter from "./Tinter"; interface MatrixClientCreds { homeserverUrl: string, @@ -134,9 +133,6 @@ class MatrixClientPeg { } } - const color_scheme = SettingsStore.getValue("roomColor"); - Tinter.tint(color_scheme.primary_color, color_scheme.secondary_color); - // Connect the matrix client to the dispatcher MatrixActionCreators.start(this.matrixClient); diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index db5e898946..f385aacd40 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -1403,6 +1403,11 @@ export default React.createClass({ break; } }); + + // Fire the tinter right on startup to ensure the default theme is applied + // A later sync can/will correct the tint to be the right value for the user + const color_scheme = SettingsStore.getValue("roomColor"); + Tinter.tint(color_scheme.primary_color, color_scheme.secondary_color); }, /**