From 12e383ef13ca8285393cab701294f5724ab9da5f Mon Sep 17 00:00:00 2001 From: Benjamin Goering Date: Mon, 10 Apr 2017 17:28:01 -0700 Subject: [PATCH] refetch streamQuery on stopIgnoringUser --- .../graphql/mutations/index.js | 33 ++++++++++++------- .../coral-framework/graphql/queries/index.js | 28 +++++++++------- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/client/coral-framework/graphql/mutations/index.js b/client/coral-framework/graphql/mutations/index.js index 64a39d108..da1603f9e 100644 --- a/client/coral-framework/graphql/mutations/index.js +++ b/client/coral-framework/graphql/mutations/index.js @@ -10,6 +10,8 @@ import IGNORE_USER from './ignoreUser.graphql'; import STOP_IGNORING_USER from './stopIgnoringUser.graphql'; import MY_IGNORED_USERS from '../queries/myIgnoredUsers.graphql'; +import STREAM_QUERY from '../queries/streamQuery.graphql'; +import {variablesForStreamQuery} from '../queries'; import commentView from '../fragments/commentView.graphql'; @@ -168,15 +170,24 @@ export const ignoreUser = graphql(IGNORE_USER, { }); export const stopIgnoringUser = graphql(STOP_IGNORING_USER, { - props: ({mutate}) => ({ - stopIgnoringUser: ({id}) => { - return mutate({ - variables: { - id, - }, - refetchQueries: [{ - query: MY_IGNORED_USERS, - }] - }); - }}), + props: ({mutate, ownProps}) => { + return { + stopIgnoringUser: ({id}) => { + return mutate({ + variables: { + id, + }, + refetchQueries: [ + { + query: MY_IGNORED_USERS, + }, + { + query: STREAM_QUERY, + variables: variablesForStreamQuery(ownProps), + } + ] + }); + } + }; + } }); diff --git a/client/coral-framework/graphql/queries/index.js b/client/coral-framework/graphql/queries/index.js index a1f8aecf0..bcf397d3c 100644 --- a/client/coral-framework/graphql/queries/index.js +++ b/client/coral-framework/graphql/queries/index.js @@ -121,21 +121,25 @@ export const loadMore = (data) => ({limit, cursor, parent_id = null, asset_id, s }); }; +export const variablesForStreamQuery = ({auth}) => { + + // where the query string is from the embeded iframe url + let comment_id = getQueryVariable('comment_id'); + let has_comment = comment_id != null; + return { + asset_id: getQueryVariable('asset_id'), + asset_url: getQueryVariable('asset_url'), + comment_id: has_comment ? comment_id : 'no-comment', + has_comment, + notIgnoredBy: (auth && auth.user) ? auth.user.id : undefined, + }; +}; + // load the comment stream. export const queryStream = graphql(STREAM_QUERY, { - options: ({auth} = {}) => { - - // where the query string is from the embeded iframe url - let comment_id = getQueryVariable('comment_id'); - let has_comment = comment_id != null; + options: (props) => { return { - variables: { - asset_id: getQueryVariable('asset_id'), - asset_url: getQueryVariable('asset_url'), - comment_id: has_comment ? comment_id : 'no-comment', - has_comment, - notIgnoredBy: (auth && auth.user) ? auth.user.id : undefined, - } + variables: variablesForStreamQuery(props) }; }, props: ({data}) => ({