You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import * as React from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { withRouter } from 'react-router';
|
|
|
|
|
|
|
|
import { EteSyncContextType } from './EteSyncContext';
|
|
|
|
|
|
|
|
import { store, JournalsType, fetchJournals, StoreState } from './store';
|
|
|
|
|
|
|
|
interface PropsType {
|
|
|
|
etesync: EteSyncContextType;
|
|
|
|
children: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface PropsTypeInner extends PropsType {
|
|
|
|
journals: JournalsType;
|
|
|
|
}
|
|
|
|
|
|
|
|
class JournalFetcher extends React.Component {
|
|
|
|
props: PropsTypeInner;
|
|
|
|
|
|
|
|
constructor(props: any) {
|
|
|
|
super(props);
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
store.dispatch(fetchJournals(this.props.etesync));
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
if (this.props.journals.value === null) {
|
|
|
|
return (<div/>);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.props.children;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapStateToProps = (state: StoreState, props: PropsType) => {
|
|
|
|
return {
|
|
|
|
journals: state.cache.journals,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default withRouter(connect(
|
|
|
|
mapStateToProps
|
|
|
|
)(JournalFetcher));
|