#48: add loader during account switching

This commit is contained in:
SleepWalker 2016-11-19 11:34:19 +02:00
parent 1449d1ac79
commit 78132e9adb
3 changed files with 16 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import classNames from 'classnames';
import { Link } from 'react-router';
import { FormattedMessage as Message } from 'react-intl';
import loader from 'services/loader';
import { skins, SKIN_DARK, COLOR_WHITE } from 'components/ui';
import { Button } from 'components/ui/form';
@ -137,9 +138,12 @@ export class AccountSwitcher extends Component {
onSwitch = (account) => (event) => {
event.preventDefault();
loader.show();
this.props.switchAccount(account)
.then(() => this.props.onAfterAction())
.then(() => this.props.onSwitch(account));
.then(() => this.props.onSwitch(account))
.finally(() => loader.hide());
};
onRemove = (account) => (event) => {

View File

@ -13,6 +13,7 @@ import { IntlProvider } from 'components/i18n';
import routesFactory from 'routes';
import storeFactory from 'storeFactory';
import bsodFactory from 'components/ui/bsod/factory';
import loader from 'services/loader';
const store = storeFactory();
@ -52,7 +53,7 @@ Promise.all([
function stopLoading() {
document.getElementById('loader').classList.remove('is-active');
loader.hide();
}
import scrollTo from 'components/ui/scrollTo';

9
src/services/loader.js Normal file
View File

@ -0,0 +1,9 @@
export default {
show() {
document.getElementById('loader').classList.add('is-active');
},
hide() {
document.getElementById('loader').classList.remove('is-active');
}
};