From 588c1c201c246f9da37b056cc3717717e442f9fc Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 11 Dec 2017 11:37:35 -0300 Subject: [PATCH] Avoiding refetch from Community --- client/coral-admin/src/graphql/index.js | 22 +++++++++++++++++++ .../src/routes/Community/containers/People.js | 1 - 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/client/coral-admin/src/graphql/index.js b/client/coral-admin/src/graphql/index.js index d5ada0557..8e701b707 100644 --- a/client/coral-admin/src/graphql/index.js +++ b/client/coral-admin/src/graphql/index.js @@ -3,6 +3,28 @@ import {mapLeaves} from 'coral-framework/utils'; export default { mutations: { + SetUserRole: ({variables: {id: userId, role}}) => ({ + updateQueries: { + TalkAdmin_Community: (prev) => { + + const updated = update(prev, { + users: { + nodes: { + $apply: (nodes) => nodes.map((node) => { + if (node.id === userId) { + node.role = role; + } + + return node; + }) + }, + }, + }); + + return updated; + } + } + }), BanUser: ({variables: {input: {id: userId}}}) => ({ updateQueries: { TalkAdmin_Community: (prev) => { diff --git a/client/coral-admin/src/routes/Community/containers/People.js b/client/coral-admin/src/routes/Community/containers/People.js index f6f84ec69..e262bf28a 100644 --- a/client/coral-admin/src/routes/Community/containers/People.js +++ b/client/coral-admin/src/routes/Community/containers/People.js @@ -36,7 +36,6 @@ class PeopleContainer extends React.Component { setUserRole = async (id, role) => { await this.props.setUserRole(id, role); - await this.fetchUsers(); } loadMore = () => {