Resetting theme upon logout. Displaying loading page when logging in so user does not see their theme switch.

Этот коммит содержится в:
Christopher Speller
2016-03-30 09:30:33 -04:00
родитель a6a0f18166
Коммит 29cc5e16bc
2 изменённых файлов: 20 добавлений и 0 удалений

Просмотреть файл

@@ -14,6 +14,7 @@ const TutorialSteps = Constants.TutorialSteps;
const Preferences = Constants.Preferences; const Preferences = Constants.Preferences;
import ErrorBar from 'components/error_bar.jsx'; import ErrorBar from 'components/error_bar.jsx';
import * as Websockets from 'action_creators/websocket_actions.jsx'; import * as Websockets from 'action_creators/websocket_actions.jsx';
import LoadingScreen from 'components/loading_screen.jsx';
import {browserHistory} from 'react-router'; import {browserHistory} from 'react-router';
@@ -44,6 +45,13 @@ export default class LoggedIn extends React.Component {
super(params); super(params);
this.onUserChanged = this.onUserChanged.bind(this); this.onUserChanged = this.onUserChanged.bind(this);
this.state = {
user: null
};
}
isValidState() {
return this.state.user != null;
} }
onUserChanged() { onUserChanged() {
// Grab the current user // Grab the current user
@@ -75,6 +83,8 @@ export default class LoggedIn extends React.Component {
if (tutorialStep <= TutorialSteps.INTRO_SCREENS) { if (tutorialStep <= TutorialSteps.INTRO_SCREENS) {
browserHistory.push(Utils.getTeamURLFromAddressBar() + '/tutorial'); browserHistory.push(Utils.getTeamURLFromAddressBar() + '/tutorial');
} }
this.setState({user});
} }
componentWillMount() { componentWillMount() {
// Emit view action // Emit view action
@@ -186,6 +196,8 @@ export default class LoggedIn extends React.Component {
Websockets.close(); Websockets.close();
UserStore.removeChangeListener(this.onUserChanged); UserStore.removeChangeListener(this.onUserChanged);
Utils.resetTheme();
$('body').off('click.userpopover'); $('body').off('click.userpopover');
$('body').off('mouseenter mouseleave', '.post'); $('body').off('mouseenter mouseleave', '.post');
$('body').off('mouseenter mouseleave', '.post.post--comment.same--root'); $('body').off('mouseenter mouseleave', '.post.post--comment.same--root');
@@ -195,6 +207,10 @@ export default class LoggedIn extends React.Component {
$(window).off('keydown.preventBackspace'); $(window).off('keydown.preventBackspace');
} }
render() { render() {
if (!this.isValidState()) {
return <LoadingScreen/>;
}
let content = []; let content = [];
if (this.props.children) { if (this.props.children) {
content = this.props.children; content = this.props.children;

Просмотреть файл

@@ -795,6 +795,10 @@ export function applyTheme(theme) {
updateCodeTheme(theme.codeTheme); updateCodeTheme(theme.codeTheme);
} }
export function resetTheme() {
applyTheme(Constants.THEMES.default);
}
export function applyFont(fontName) { export function applyFont(fontName) {
const body = $('body'); const body = $('body');