From d0d047f6414f06b4d1183c1b7e58c71631d59413 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Fri, 8 Dec 2017 15:04:33 -0700 Subject: [PATCH] fixed bug with load more --- client/coral-embed-stream/src/actions/auth.js | 8 ++++++-- client/coral-embed-stream/src/graphql/utils.js | 10 +++++----- .../src/tabs/stream/containers/Stream.js | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/client/coral-embed-stream/src/actions/auth.js b/client/coral-embed-stream/src/actions/auth.js index 22d46a768..4599a1cc7 100644 --- a/client/coral-embed-stream/src/actions/auth.js +++ b/client/coral-embed-stream/src/actions/auth.js @@ -304,6 +304,8 @@ const checkLoginSuccess = (user, isAdmin) => ({ isAdmin }); +const ErrNotLoggedIn = new Error('Not logged in'); + export const checkLogin = () => (dispatch, _, {rest, client, pym, storage}) => { dispatch(checkLoginRequest()); rest('/auth') @@ -312,7 +314,7 @@ export const checkLogin = () => (dispatch, _, {rest, client, pym, storage}) => { if (storage) { storage.removeItem('token'); } - throw new Error('Not logged in'); + throw ErrNotLoggedIn; } // Reset the websocket. @@ -327,7 +329,9 @@ export const checkLogin = () => (dispatch, _, {rest, client, pym, storage}) => { } }) .catch((error) => { - console.error(error); + if (error !== ErrNotLoggedIn) { + console.error(error); + } if (error.status && error.status === 401 && storage) { // Unauthorized. diff --git a/client/coral-embed-stream/src/graphql/utils.js b/client/coral-embed-stream/src/graphql/utils.js index 0c46b45e3..8ab24d91f 100644 --- a/client/coral-embed-stream/src/graphql/utils.js +++ b/client/coral-embed-stream/src/graphql/utils.js @@ -141,18 +141,18 @@ export function findCommentWithId(nodes, id) { return findComment(nodes, (node) => node.id === id); } -export function findCommentInEmbedQuery(root, callbackOrId) { +export function findCommentInEmbedQuery(props, callbackOrId) { let callback = callbackOrId; if (typeof callbackOrId === 'string') { callback = (node) => node.id === callbackOrId; } - if (root.asset.comment) { - return findComment([getTopLevelParent(root.asset.comment)], callback); + if (props.asset.comment) { + return findComment([getTopLevelParent(props.asset.comment)], callback); } - if (!root.asset.comments) { + if (!props.asset.comments) { return false; } - return findComment(root.asset.comments.nodes, callback); + return findComment(props.asset.comments.nodes, callback); } function findAndInsertFetchedComments(parent, comments, parent_id) { diff --git a/client/coral-embed-stream/src/tabs/stream/containers/Stream.js b/client/coral-embed-stream/src/tabs/stream/containers/Stream.js index dad69b960..b4f375632 100644 --- a/client/coral-embed-stream/src/tabs/stream/containers/Stream.js +++ b/client/coral-embed-stream/src/tabs/stream/containers/Stream.js @@ -108,7 +108,7 @@ class StreamContainer extends React.Component { } loadNewReplies = (parent_id) => { - const comment = findCommentInEmbedQuery(this.props.root, parent_id); + const comment = findCommentInEmbedQuery(this.props, parent_id); return this.props.data.fetchMore({ query: LOAD_MORE_QUERY,