fixed bug with load more

This commit is contained in:
Wyatt Johnson
2017-12-08 15:04:33 -07:00
parent ba572fbf48
commit d0d047f641
3 changed files with 12 additions and 8 deletions
@@ -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.
@@ -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) {
@@ -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,