mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 18:11:40 -05:00
pass error to PostsList and show error message
This commit is contained in:
parent
afebadba55
commit
cf1ee06273
3 changed files with 17 additions and 4 deletions
|
@ -3,14 +3,25 @@ import React from 'react';
|
|||
import { withList } from 'meteor/nova:core';
|
||||
import Posts from 'meteor/nova:posts';
|
||||
import { withCurrentUser } from 'meteor/nova:core';
|
||||
import { Alert } from 'react-bootstrap';
|
||||
|
||||
const PostsList = (props) => {
|
||||
|
||||
const {results, loading, count, totalCount, loadMore, showHeader = true, networkStatus, currentUser} = props;
|
||||
const {results, loading, count, totalCount, loadMore, showHeader = true, networkStatus, currentUser, error} = props;
|
||||
|
||||
const loadingMore = networkStatus === 2;
|
||||
|
||||
if (results && results.length) {
|
||||
if (error) {
|
||||
|
||||
return (
|
||||
<div className="posts-list">
|
||||
<Alert className="flash-message" bsStyle="danger">
|
||||
{error.message}
|
||||
</Alert>
|
||||
</div>
|
||||
)
|
||||
|
||||
} else if (results && results.length) {
|
||||
|
||||
const hasMore = totalCount > results.length;
|
||||
|
||||
|
|
|
@ -110,7 +110,8 @@ const withList = (options) => {
|
|||
// results = Utils.convertDates(collection, props.data[listResolverName]),
|
||||
results = props.data[listResolverName],
|
||||
totalCount = props.data[totalResolverName],
|
||||
networkStatus = props.data.networkStatus;
|
||||
networkStatus = props.data.networkStatus,
|
||||
error = props.data.error;
|
||||
|
||||
return {
|
||||
// see https://github.com/apollostack/apollo-client/blob/master/src/queries/store.ts#L28-L36
|
||||
|
@ -120,6 +121,7 @@ const withList = (options) => {
|
|||
totalCount,
|
||||
refetch,
|
||||
networkStatus,
|
||||
error,
|
||||
count: results && results.length,
|
||||
|
||||
// regular load more (reload everything)
|
||||
|
|
|
@ -47,7 +47,7 @@ Meteor.startup(function initNovaRoutesAndApollo() {
|
|||
|
||||
// configure apollo
|
||||
client = new ApolloClient(meteorClientConfig());
|
||||
var apolloClientReducer = (state = initialState.apollo, action) => {
|
||||
var apolloClientReducer = (state = initialState && initialState.apollo, action) => {
|
||||
return client.reducer()(state, action);
|
||||
};
|
||||
addReducer({apollo: apolloClientReducer});
|
||||
|
|
Loading…
Add table
Reference in a new issue