diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-04-25 11:46:02 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-04-25 11:46:02 -0400 |
commit | 6c4c706313eb765eb00c639f381646be74f27b69 (patch) | |
tree | 6068feaa9668dcd74601730ac1a5abfb366402b1 /webapp/root.jsx | |
parent | cc07c005074348de87854f1c953a549e8772fa03 (diff) | |
download | chat-6c4c706313eb765eb00c639f381646be74f27b69.tar.gz chat-6c4c706313eb765eb00c639f381646be74f27b69.tar.bz2 chat-6c4c706313eb765eb00c639f381646be74f27b69.zip |
Start moving webapp to Redux (#6140)
* Start moving webapp to Redux
* Fix localforage import
* Updates per feedback
* Feedback udpates and a few fixes
* Minor updates
* Fix statuses, config not loading properly, getMe sanitizing too much
* Fix preferences
* Fix user autocomplete
* Fix sessions and audits
* Fix error handling for all redux actions
* Use new directory structure for components and containers
* Refresh immediately on logout instead of after timeout
* Add fetch polyfill
Diffstat (limited to 'webapp/root.jsx')
-rw-r--r-- | webapp/root.jsx | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/webapp/root.jsx b/webapp/root.jsx index 177eb1ec4..b2da6a54c 100644 --- a/webapp/root.jsx +++ b/webapp/root.jsx @@ -6,22 +6,28 @@ require('perfect-scrollbar/jquery')($); import React from 'react'; import ReactDOM from 'react-dom'; +import {Provider} from 'react-redux'; import {Router, browserHistory} from 'react-router/es6'; import PDFJS from 'pdfjs-dist'; -import * as GlobalActions from 'actions/global_actions.jsx'; + import * as Websockets from 'actions/websocket_actions.jsx'; +import {loadMeAndConfig} from 'actions/user_actions.jsx'; import BrowserStore from 'stores/browser_store.jsx'; import ChannelStore from 'stores/channel_store.jsx'; import UserStore from 'stores/user_store.jsx'; import * as I18n from 'i18n/i18n.jsx'; import * as AsyncClient from 'utils/async_client.jsx'; +import {getClientConfig, getLicenseConfig, setUrl} from 'mattermost-redux/actions/general'; + // Import our styles import 'bootstrap-colorpicker/dist/css/bootstrap-colorpicker.css'; import 'google-fonts/google-fonts.css'; import 'sass/styles.scss'; import 'katex/dist/katex.min.css'; +import store from 'stores/redux_store.jsx'; + // Import the root of our routing tree import rRoot from 'routes/route_root.jsx'; @@ -51,11 +57,26 @@ function preRenderSetup(callwhendone) { var d1 = $.Deferred(); //eslint-disable-line new-cap - GlobalActions.emitInitialLoad( - () => { - d1.resolve(); - } - ); + setUrl(window.location.origin); + + const currentUserId = localStorage.getItem('currentUserId'); + + if (currentUserId) { + loadMeAndConfig(() => d1.resolve()); + } else { + getClientConfig()(store.dispatch, store.getState).then( + (config) => { + global.window.mm_config = config; + + getLicenseConfig()(store.dispatch, store.getState).then( + (license) => { + global.window.mm_license = license; + d1.resolve(); + } + ); + } + ); + } // Make sure the websockets close and reset version $(window).on('beforeunload', @@ -86,10 +107,12 @@ function preRenderSetup(callwhendone) { function renderRootComponent() { ReactDOM.render(( - <Router - history={browserHistory} - routes={rRoot} - /> + <Provider store={store}> + <Router + history={browserHistory} + routes={rRoot} + /> + </Provider> ), document.getElementById('root')); } |