Fix infinite loading indicator when there are no entries.

master
Tom Hacohen 6 years ago
parent 9f4fb75d73
commit a8c6b30456

@ -36,6 +36,7 @@ type PropsTypeInner = RouteComponentProps<{}> & PropsType & {
journals: JournalsType; journals: JournalsType;
entries: EntriesType; entries: EntriesType;
userInfo: UserInfoType; userInfo: UserInfoType;
fetchCount: number;
}; };
const syncInfoSelector = createSelector( const syncInfoSelector = createSelector(
@ -167,8 +168,9 @@ class SyncGate extends React.PureComponent<PropsTypeInner> {
} }
if ((this.props.userInfo.value === null) || (journals === null) || if ((this.props.userInfo.value === null) || (journals === null) ||
(entryArrays.size === 0) || ((this.props.fetchCount > 0) &&
!entryArrays.every((x: any) => (x.value !== null))) { ((entryArrays.size === 0) || !entryArrays.every((x: any) => (x.value !== null))))
) {
return (<LoadingIndicator style={{display: 'block', margin: '40px auto'}} />); return (<LoadingIndicator style={{display: 'block', margin: '40px auto'}} />);
} }
@ -213,6 +215,7 @@ const mapStateToProps = (state: StoreState, props: PropsType) => {
journals: state.cache.journals, journals: state.cache.journals,
entries: state.cache.entries, entries: state.cache.entries,
userInfo: state.cache.userInfo, userInfo: state.cache.userInfo,
fetchCount: state.fetchCount,
}; };
}; };

Loading…
Cancel
Save