mirror of
				https://github.com/vector-im/element-web.git
				synced 2025-11-04 02:02:14 +01:00 
			
		
		
		
	Merge pull request #4014 from matrix-org/dbkr/theme_is_login_override
Add an override for the theme
This commit is contained in:
		
						commit
						85489c4ec5
					
				@ -53,6 +53,7 @@ import createRoom from "../../createRoom";
 | 
				
			|||||||
import KeyRequestHandler from '../../KeyRequestHandler';
 | 
					import KeyRequestHandler from '../../KeyRequestHandler';
 | 
				
			||||||
import { _t, getCurrentLanguage } from '../../languageHandler';
 | 
					import { _t, getCurrentLanguage } from '../../languageHandler';
 | 
				
			||||||
import SettingsStore, {SettingLevel} from "../../settings/SettingsStore";
 | 
					import SettingsStore, {SettingLevel} from "../../settings/SettingsStore";
 | 
				
			||||||
 | 
					import ThemeController from "../../settings/controllers/ThemeController";
 | 
				
			||||||
import { startAnyRegistrationFlow } from "../../Registration.js";
 | 
					import { startAnyRegistrationFlow } from "../../Registration.js";
 | 
				
			||||||
import { messageForSyncError } from '../../utils/ErrorUtils';
 | 
					import { messageForSyncError } from '../../utils/ErrorUtils';
 | 
				
			||||||
import ResizeNotifier from "../../utils/ResizeNotifier";
 | 
					import ResizeNotifier from "../../utils/ResizeNotifier";
 | 
				
			||||||
@ -506,6 +507,8 @@ export default createReactClass({
 | 
				
			|||||||
                    view: VIEWS.LOGIN,
 | 
					                    view: VIEWS.LOGIN,
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
                this.notifyNewScreen('login');
 | 
					                this.notifyNewScreen('login');
 | 
				
			||||||
 | 
					                ThemeController.isLogin = true;
 | 
				
			||||||
 | 
					                this._themeWatcher.recheck();
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case 'start_post_registration':
 | 
					            case 'start_post_registration':
 | 
				
			||||||
                this.setState({
 | 
					                this.setState({
 | 
				
			||||||
@ -760,6 +763,8 @@ export default createReactClass({
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.setStateForNewView(newState);
 | 
					        this.setStateForNewView(newState);
 | 
				
			||||||
 | 
					        ThemeController.isLogin = true;
 | 
				
			||||||
 | 
					        this._themeWatcher.recheck();
 | 
				
			||||||
        this.notifyNewScreen('register');
 | 
					        this.notifyNewScreen('register');
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -910,6 +915,8 @@ export default createReactClass({
 | 
				
			|||||||
            view: VIEWS.WELCOME,
 | 
					            view: VIEWS.WELCOME,
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        this.notifyNewScreen('welcome');
 | 
					        this.notifyNewScreen('welcome');
 | 
				
			||||||
 | 
					        ThemeController.isLogin = true;
 | 
				
			||||||
 | 
					        this._themeWatcher.recheck();
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _viewHome: function() {
 | 
					    _viewHome: function() {
 | 
				
			||||||
@ -919,6 +926,8 @@ export default createReactClass({
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
        this._setPage(PageTypes.HomePage);
 | 
					        this._setPage(PageTypes.HomePage);
 | 
				
			||||||
        this.notifyNewScreen('home');
 | 
					        this.notifyNewScreen('home');
 | 
				
			||||||
 | 
					        ThemeController.isLogin = false;
 | 
				
			||||||
 | 
					        this._themeWatcher.recheck();
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _viewUser: function(userId, subAction) {
 | 
					    _viewUser: function(userId, subAction) {
 | 
				
			||||||
@ -1231,6 +1240,8 @@ export default createReactClass({
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
        this.subTitleStatus = '';
 | 
					        this.subTitleStatus = '';
 | 
				
			||||||
        this._setPageSubtitle();
 | 
					        this._setPageSubtitle();
 | 
				
			||||||
 | 
					        ThemeController.isLogin = true;
 | 
				
			||||||
 | 
					        this._themeWatcher.recheck();
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 | 
				
			|||||||
@ -19,9 +19,13 @@ import SettingController from "./SettingController";
 | 
				
			|||||||
import {DEFAULT_THEME, enumerateThemes} from "../../theme";
 | 
					import {DEFAULT_THEME, enumerateThemes} from "../../theme";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default class ThemeController extends SettingController {
 | 
					export default class ThemeController extends SettingController {
 | 
				
			||||||
 | 
					    static isLogin = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    getValueOverride(level, roomId, calculatedValue, calculatedAtLevel) {
 | 
					    getValueOverride(level, roomId, calculatedValue, calculatedAtLevel) {
 | 
				
			||||||
        if (!calculatedValue) return null; // Don't override null themes
 | 
					        if (!calculatedValue) return null; // Don't override null themes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (ThemeController.isLogin) return 'light';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const themes = enumerateThemes();
 | 
					        const themes = enumerateThemes();
 | 
				
			||||||
        // Override in case some no longer supported theme is stored here
 | 
					        // Override in case some no longer supported theme is stored here
 | 
				
			||||||
        if (!themes[calculatedValue]) {
 | 
					        if (!themes[calculatedValue]) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user