From 3a551f2da5c94a279a89349104a22e6223eb643e Mon Sep 17 00:00:00 2001 From: The Stranjer <791672+TheStranjer@users.noreply.github.com> Date: Fri, 17 Apr 2020 06:31:49 -0400 Subject: [PATCH 1/2] Allow admins to create an array of backgrounds to be randomly chosen from --- docs/config.md | 2 +- src/components/views/auth/VectorAuthPage.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/config.md b/docs/config.md index 3102eaf8..a1d6304e 100644 --- a/docs/config.md +++ b/docs/config.md @@ -32,7 +32,7 @@ For a good example, see https://riot.im/develop/config.json. homeserver know what email template to use when talking to you. 1. `branding`: Configures various branding and logo details, such as: 1. `welcomeBackgroundUrl`: An image to use as a wallpaper outside the app - during authentication flows + during authentication flows. If an array is passed, an image is chosen randomly for each visit. 1. `authHeaderLogoUrl`: An logo image that is shown in the header during authentication flows 1. `authFooterLinks`: a list of links to show in the authentication page footer: diff --git a/src/components/views/auth/VectorAuthPage.js b/src/components/views/auth/VectorAuthPage.js index 98ddb8ba..b1cd7c22 100644 --- a/src/components/views/auth/VectorAuthPage.js +++ b/src/components/views/auth/VectorAuthPage.js @@ -29,7 +29,11 @@ export default class VectorAuthPage extends React.PureComponent { const brandingConfig = SdkConfig.get().branding; let backgroundUrl = "themes/riot/img/backgrounds/valley.jpg"; if (brandingConfig && brandingConfig.welcomeBackgroundUrl) { - backgroundUrl = brandingConfig.welcomeBackgroundUrl; + if (Array.isArray(brandingConfig.welcomeBackgroundUrl)) { + backgroundUrl = brandingConfig.welcomeBackgroundUrl[ Math.floor(Math.random() * brandingConfig.welcomeBackgroundUrl.length)]; + } else { + backgroundUrl = brandingConfig.welcomeBackgroundUrl; + } } const pageStyle = { From b3f31265835f04330094c9807b3f81e124cb14bd Mon Sep 17 00:00:00 2001 From: The Stranjer <791672+TheStranjer@users.noreply.github.com> Date: Fri, 17 Apr 2020 06:52:43 -0400 Subject: [PATCH 2/2] Better conformity to JS linter --- src/components/views/auth/VectorAuthPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/auth/VectorAuthPage.js b/src/components/views/auth/VectorAuthPage.js index b1cd7c22..13b43ca1 100644 --- a/src/components/views/auth/VectorAuthPage.js +++ b/src/components/views/auth/VectorAuthPage.js @@ -30,7 +30,7 @@ export default class VectorAuthPage extends React.PureComponent { let backgroundUrl = "themes/riot/img/backgrounds/valley.jpg"; if (brandingConfig && brandingConfig.welcomeBackgroundUrl) { if (Array.isArray(brandingConfig.welcomeBackgroundUrl)) { - backgroundUrl = brandingConfig.welcomeBackgroundUrl[ Math.floor(Math.random() * brandingConfig.welcomeBackgroundUrl.length)]; + backgroundUrl = brandingConfig.welcomeBackgroundUrl[Math.floor(Math.random() * brandingConfig.welcomeBackgroundUrl.length)]; } else { backgroundUrl = brandingConfig.welcomeBackgroundUrl; }