refetch streamQuery on stopIgnoringUser

This commit is contained in:
Benjamin Goering
2017-04-10 17:28:01 -07:00
parent a43e713ac0
commit 12e383ef13
2 changed files with 38 additions and 23 deletions
@@ -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),
}
]
});
}
};
}
});
+16 -12
View File
@@ -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}) => ({