diff --git a/src/Journal.tsx b/src/Journal.tsx index 2b466bb..cc9de60 100644 --- a/src/Journal.tsx +++ b/src/Journal.tsx @@ -1,6 +1,4 @@ import * as React from 'react'; -import { connect } from 'react-redux'; -import { withRouter } from 'react-router'; import { Tabs, Tab } from 'material-ui/Tabs'; import * as EteSync from './api/EteSync'; @@ -12,16 +10,16 @@ import LoadingIndicator from './LoadingIndicator'; import { syncEntriesToItemMap, syncEntriesToCalendarItemMap } from './journal-processors'; -import { store, StoreState, JournalsData, EntriesType, CredentialsData, fetchEntries } from './store'; +import { JournalsData, EntriesType, CredentialsData } from './store'; interface PropsType { journals: JournalsData; + entries: EntriesType; etesync: CredentialsData; match: any; } interface PropsTypeInner extends PropsType { - entries: EntriesType; } class Journal extends React.Component { @@ -35,12 +33,6 @@ class Journal extends React.Component { super(props); } - componentDidMount() { - const journal = this.props.match.params.journalUid; - - store.dispatch(fetchEntries(this.props.etesync, journal, null)); - } - render() { const journalUid = this.props.match.params.journalUid; const entries = this.props.entries[journalUid]; @@ -99,12 +91,4 @@ class Journal extends React.Component { } } -const mapStateToProps = (state: StoreState, props: PropsType) => { - return { - entries: state.cache.entries, - }; -}; - -export default withRouter(connect( - mapStateToProps -)(Journal)); +export default Journal; diff --git a/src/SyncGate.tsx b/src/SyncGate.tsx index 4a5209b..d26e29d 100644 --- a/src/SyncGate.tsx +++ b/src/SyncGate.tsx @@ -1,9 +1,12 @@ import * as React from 'react'; import { connect } from 'react-redux'; -import { withRouter } from 'react-router'; +import { Route, Switch, withRouter } from 'react-router'; + +import { routeResolver } from './App'; import LoadingIndicator from './LoadingIndicator'; +import Journal from './Journal'; import Main from './Main'; import { store, JournalsType, EntriesType, fetchJournals, fetchEntries, StoreState, CredentialsData } from './store'; @@ -57,13 +60,30 @@ class SyncGate extends React.Component { return this.props.entries[key].value; }); - if ((this.props.journals.value === null) || + const journals = this.props.journals.value; + + if ((journals === null) || (entryArrays.length === 0) || !entryArrays.every((x: any) => (x !== null))) { return (); } return ( -
+ + ( +
+ ) + } + /> + ( + + )} + /> + ); } }