11/*
2- Copyright 2019 New Vector Ltd
2+ Copyright 2019, 2020 New Vector Ltd
33
44Licensed under the Apache License, Version 2.0 (the "License");
55you may not use this file except in compliance with the License.
@@ -14,30 +14,38 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- 'use strict' ;
18-
1917import React from 'react' ;
2018import * as sdk from 'matrix-react-sdk/src/index' ;
2119import SdkConfig from 'matrix-react-sdk/src/SdkConfig' ;
2220
2321export default class VectorAuthPage extends React . PureComponent {
2422 static replaces = 'AuthPage'
2523
26- render ( ) {
27- const AuthFooter = sdk . getComponent ( 'auth.AuthFooter' ) ;
24+ static welcomeBackgroundUrl ;
25+
26+ // cache the url as a static to prevent it changing without refreshing
27+ static getWelcomeBackgroundUrl ( ) {
28+ if ( VectorAuthPage . welcomeBackgroundUrl ) return VectorAuthPage . welcomeBackgroundUrl ;
2829
2930 const brandingConfig = SdkConfig . get ( ) . branding ;
30- let backgroundUrl = "themes/riot/img/backgrounds/valley.jpg" ;
31+ VectorAuthPage . welcomeBackgroundUrl = "themes/riot/img/backgrounds/valley.jpg" ;
3132 if ( brandingConfig && brandingConfig . welcomeBackgroundUrl ) {
3233 if ( Array . isArray ( brandingConfig . welcomeBackgroundUrl ) ) {
33- backgroundUrl = brandingConfig . welcomeBackgroundUrl [ Math . floor ( Math . random ( ) * brandingConfig . welcomeBackgroundUrl . length ) ] ;
34+ const index = Math . floor ( Math . random ( ) * brandingConfig . welcomeBackgroundUrl . length ) ;
35+ VectorAuthPage . welcomeBackgroundUrl = brandingConfig . welcomeBackgroundUrl [ index ] ;
3436 } else {
35- backgroundUrl = brandingConfig . welcomeBackgroundUrl ;
37+ VectorAuthPage . welcomeBackgroundUrl = brandingConfig . welcomeBackgroundUrl ;
3638 }
3739 }
3840
41+ return VectorAuthPage . welcomeBackgroundUrl ;
42+ }
43+
44+ render ( ) {
45+ const AuthFooter = sdk . getComponent ( 'auth.AuthFooter' ) ;
46+
3947 const pageStyle = {
40- background : `center/cover fixed url(${ backgroundUrl } )` ,
48+ background : `center/cover fixed url(${ VectorAuthPage . getWelcomeBackgroundUrl ( ) } )` ,
4149 } ;
4250
4351 const modalStyle = {
@@ -65,7 +73,7 @@ export default class VectorAuthPage extends React.PureComponent {
6573 return (
6674 < div className = "mx_AuthPage" style = { pageStyle } >
6775 < div className = "mx_AuthPage_modal" style = { modalStyle } >
68- < div className = "mx_AuthPage_modalBlur" style = { blurStyle } > </ div >
76+ < div className = "mx_AuthPage_modalBlur" style = { blurStyle } / >
6977 < div className = "mx_AuthPage_modalContent" style = { modalContentStyle } >
7078 { this . props . children }
7179 </ div >
0 commit comments