Migrated user/team/auth from redux to mobx

This commit is contained in:
Jori Lallo
2016-06-04 15:53:08 -07:00
parent 6a5303149d
commit e5d1612cbf
13 changed files with 129 additions and 194 deletions

View File

@@ -88,7 +88,7 @@ const documentEditState = new class DocumentEditState {
}
constructor() {
// Rehydrate
// Rehydrate syncronously
localforage.getItem(DOCUMENT_EDIT_SETTINGS)
.then(data => {
this.preview = data.preview;

View File

@@ -1,22 +1,15 @@
import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { replace } from 'react-router-redux';
import auth from '../../utils/auth';
import store from 'stores/UserStore';
import { browserHistory } from 'react-router'
import SlackAuthLink from '../../components/SlackAuthLink';
import styles from './Home.scss';
class Home extends React.Component {
static propTypes = {
replace: React.PropTypes.func.isRequired,
}
export default class Home extends React.Component {
componentDidMount = () => {
if (auth.loggedIn()) {
this.props.replace('/dashboard');
if (store.authenticated) {
browserHistory.replace('/dashboard');
}
}
@@ -53,11 +46,3 @@ class Home extends React.Component {
);
}
}
const mapDispatchToProps = (dispatch) => {
return bindActionCreators({ replace }, dispatch)
}
export default connect(
null, mapDispatchToProps
)(Home);

View File

@@ -1,21 +1,10 @@
import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import store from 'stores/UserStore';
import { slackAuthAsync } from '../../actions/SlackAuthAction';
import { client } from '../../utils/ApiClient';
class SlackAuth extends React.Component {
export default class SlackAuth extends React.Component {
componentDidMount = () => {
const { query } = this.props.location
// Validate OAuth2 state param
if (localStorage.oauthState != query.state) {
return;
}
this.props.slackAuthAsync(query.code);
const { code, state } = this.props.location.query;
store.authWithSlack(code, state);
}
render() {
@@ -24,12 +13,3 @@ class SlackAuth extends React.Component {
);
}
}
const mapDispactcToProps = (dispatch) => {
return bindActionCreators({ slackAuthAsync }, dispatch);
};
export default connect(
null,
mapDispactcToProps
)(SlackAuth);