| 
									
										
										
										
											2020-03-27 20:59:38 +00:00
										 |  |  | 'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import React from 'react'; | 
					
						
							|  |  |  | import { Provider, connect } from 'react-redux'; | 
					
						
							|  |  |  | import PropTypes from 'prop-types'; | 
					
						
							| 
									
										
										
										
											2020-04-15 04:21:36 +00:00
										 |  |  | import Helmet from 'gabsocial/components/helmet'; | 
					
						
							| 
									
										
										
										
											2020-04-21 20:05:49 +00:00
										 |  |  | import classNames from 'classnames'; | 
					
						
							| 
									
										
										
										
											2020-03-27 20:59:38 +00:00
										 |  |  | import configureStore from '../store/configureStore'; | 
					
						
							|  |  |  | import { INTRODUCTION_VERSION } from '../actions/onboarding'; | 
					
						
							| 
									
										
										
										
											2020-04-08 23:38:22 +00:00
										 |  |  | import { Switch, BrowserRouter, Route } from 'react-router-dom'; | 
					
						
							| 
									
										
										
										
											2020-03-27 20:59:38 +00:00
										 |  |  | import { ScrollContext } from 'react-router-scroll-4'; | 
					
						
							|  |  |  | import UI from '../features/ui'; | 
					
						
							| 
									
										
										
										
											2020-04-14 20:45:38 +00:00
										 |  |  | // import Introduction from '../features/introduction';
 | 
					
						
							| 
									
										
										
										
											2020-03-27 20:59:38 +00:00
										 |  |  | import { fetchCustomEmojis } from '../actions/custom_emojis'; | 
					
						
							|  |  |  | import { hydrateStore } from '../actions/store'; | 
					
						
							|  |  |  | import { IntlProvider, addLocaleData } from 'react-intl'; | 
					
						
							|  |  |  | import { getLocale } from '../locales'; | 
					
						
							|  |  |  | import initialState from '../initial_state'; | 
					
						
							|  |  |  | import ErrorBoundary from '../components/error_boundary'; | 
					
						
							| 
									
										
										
										
											2020-04-01 20:05:52 +00:00
										 |  |  | import { fetchInstance } from 'gabsocial/actions/instance'; | 
					
						
							| 
									
										
										
										
											2020-04-01 19:38:08 +00:00
										 |  |  | import { fetchSoapboxConfig } from 'gabsocial/actions/soapbox'; | 
					
						
							| 
									
										
										
										
											2020-04-02 02:20:47 +00:00
										 |  |  | import { fetchMe } from 'gabsocial/actions/me'; | 
					
						
							| 
									
										
										
										
											2020-04-08 23:38:22 +00:00
										 |  |  | import LandingPage from 'gabsocial/features/landing_page'; | 
					
						
							| 
									
										
										
										
											2020-03-27 20:59:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | const { localeData, messages } = getLocale(); | 
					
						
							|  |  |  | addLocaleData(localeData); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export const store = configureStore(); | 
					
						
							|  |  |  | const hydrateAction = hydrateStore(initialState); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | store.dispatch(hydrateAction); | 
					
						
							| 
									
										
										
										
											2020-04-02 02:20:47 +00:00
										 |  |  | store.dispatch(fetchMe()); | 
					
						
							| 
									
										
										
										
											2020-04-01 20:05:52 +00:00
										 |  |  | store.dispatch(fetchInstance()); | 
					
						
							| 
									
										
										
										
											2020-04-01 19:38:08 +00:00
										 |  |  | store.dispatch(fetchSoapboxConfig()); | 
					
						
							| 
									
										
										
										
											2020-04-01 20:05:52 +00:00
										 |  |  | store.dispatch(fetchCustomEmojis()); | 
					
						
							| 
									
										
										
										
											2020-03-27 20:59:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | const mapStateToProps = (state) => { | 
					
						
							| 
									
										
										
										
											2020-04-02 02:20:47 +00:00
										 |  |  |   const me = state.get('me'); | 
					
						
							| 
									
										
										
										
											2020-03-27 20:59:38 +00:00
										 |  |  |   const account = state.getIn(['accounts', me]); | 
					
						
							|  |  |  |   const showIntroduction = account ? state.getIn(['settings', 'introductionVersion'], 0) < INTRODUCTION_VERSION : false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return { | 
					
						
							|  |  |  |     showIntroduction, | 
					
						
							| 
									
										
										
										
											2020-04-08 23:38:22 +00:00
										 |  |  |     me, | 
					
						
							| 
									
										
										
										
											2020-04-18 18:58:51 +00:00
										 |  |  |     theme: state.getIn(['settings', 'theme']), | 
					
						
							| 
									
										
										
										
											2020-04-21 20:05:49 +00:00
										 |  |  |     systemFont: state.getIn(['settings', 'systemFont']), | 
					
						
							| 
									
										
										
										
											2020-04-21 20:10:45 +00:00
										 |  |  |     dyslexicFont: state.getIn(['settings', 'dyslexicFont']), | 
					
						
							| 
									
										
										
										
											2020-04-21 20:14:06 +00:00
										 |  |  |     demetricator: state.getIn(['settings', 'demetricator']), | 
					
						
							| 
									
										
										
										
											2020-04-14 18:44:40 +00:00
										 |  |  |   }; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2020-03-27 20:59:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | @connect(mapStateToProps) | 
					
						
							|  |  |  | class GabSocialMount extends React.PureComponent { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   static propTypes = { | 
					
						
							|  |  |  |     showIntroduction: PropTypes.bool, | 
					
						
							| 
									
										
										
										
											2020-04-14 21:37:17 +00:00
										 |  |  |     me: PropTypes.string, | 
					
						
							| 
									
										
										
										
											2020-04-15 03:09:59 +00:00
										 |  |  |     theme: PropTypes.string, | 
					
						
							| 
									
										
										
										
											2020-04-21 20:05:49 +00:00
										 |  |  |     systemFont: PropTypes.bool, | 
					
						
							| 
									
										
										
										
											2020-04-21 20:10:45 +00:00
										 |  |  |     dyslexicFont: PropTypes.bool, | 
					
						
							| 
									
										
										
										
											2020-04-21 20:14:06 +00:00
										 |  |  |     demetricator: PropTypes.bool, | 
					
						
							| 
									
										
										
										
											2020-03-27 20:59:38 +00:00
										 |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-14 21:47:35 +00:00
										 |  |  |   render() { | 
					
						
							| 
									
										
										
										
											2020-04-21 20:14:06 +00:00
										 |  |  |     const { me, theme, systemFont, dyslexicFont, demetricator } = this.props; | 
					
						
							| 
									
										
										
										
											2020-04-14 20:45:38 +00:00
										 |  |  |     if (me === null) return null; | 
					
						
							| 
									
										
										
										
											2020-04-08 23:38:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-27 20:59:38 +00:00
										 |  |  |     // Disabling introduction for launch
 | 
					
						
							|  |  |  |     // const { showIntroduction } = this.props;
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     // if (showIntroduction) {
 | 
					
						
							|  |  |  |     //   return <Introduction />;
 | 
					
						
							|  |  |  |     // }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-21 20:05:49 +00:00
										 |  |  |     const bodyClass = classNames('app-body', { | 
					
						
							|  |  |  |       [`theme-${theme}`]: theme, | 
					
						
							|  |  |  |       'system-font': systemFont, | 
					
						
							| 
									
										
										
										
											2020-04-21 20:10:45 +00:00
										 |  |  |       'dyslexic': dyslexicFont, | 
					
						
							| 
									
										
										
										
											2020-04-21 20:14:06 +00:00
										 |  |  |       'demetricator': demetricator, | 
					
						
							| 
									
										
										
										
											2020-04-21 20:05:49 +00:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-27 20:59:38 +00:00
										 |  |  |     return ( | 
					
						
							| 
									
										
										
										
											2020-04-15 03:09:59 +00:00
										 |  |  |       <> | 
					
						
							|  |  |  |         <Helmet> | 
					
						
							| 
									
										
										
										
											2020-04-21 20:05:49 +00:00
										 |  |  |           <body className={bodyClass} /> | 
					
						
							| 
									
										
										
										
											2020-04-15 03:09:59 +00:00
										 |  |  |           {theme && <link rel='stylesheet' href={`/packs/css/${theme}.chunk.css`} />} | 
					
						
							|  |  |  |         </Helmet> | 
					
						
							|  |  |  |         <BrowserRouter basename='/web'> | 
					
						
							|  |  |  |           <ScrollContext> | 
					
						
							|  |  |  |             <Switch> | 
					
						
							|  |  |  |               {!me && <Route exact path='/' component={LandingPage} />} | 
					
						
							|  |  |  |               <Route path='/' component={UI} /> | 
					
						
							|  |  |  |             </Switch> | 
					
						
							|  |  |  |           </ScrollContext> | 
					
						
							|  |  |  |         </BrowserRouter> | 
					
						
							|  |  |  |       </> | 
					
						
							| 
									
										
										
										
											2020-03-27 20:59:38 +00:00
										 |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default class GabSocial extends React.PureComponent { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   static propTypes = { | 
					
						
							|  |  |  |     locale: PropTypes.string.isRequired, | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-14 21:47:35 +00:00
										 |  |  |   render() { | 
					
						
							| 
									
										
										
										
											2020-03-27 20:59:38 +00:00
										 |  |  |     const { locale } = this.props; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return ( | 
					
						
							|  |  |  |       <IntlProvider locale={locale} messages={messages}> | 
					
						
							|  |  |  |         <Provider store={store}> | 
					
						
							|  |  |  |           <ErrorBoundary> | 
					
						
							|  |  |  |             <GabSocialMount /> | 
					
						
							|  |  |  |           </ErrorBoundary> | 
					
						
							|  |  |  |         </Provider> | 
					
						
							|  |  |  |       </IntlProvider> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |