mirror of
https://github.com/wassname/talk.git
synced 2026-07-13 16:24:39 +08:00
Handle IgnoreUser mutation errors
We now check if the IgnoreUser mutation returned an error before updating the apollo store. If the mutation returns an error we keep the store as it is, otherwise the user is added to the ignore list.
This commit is contained in:
@@ -3,6 +3,7 @@ import IgnoreUserConfirmation from './containers/IgnoreUserConfirmation';
|
||||
import IgnoredUserSection from './containers/IgnoredUserSection';
|
||||
import translations from './translations.yml';
|
||||
import update from 'immutability-helper';
|
||||
import get from 'lodash/get';
|
||||
|
||||
export default {
|
||||
slots: {
|
||||
@@ -14,7 +15,11 @@ export default {
|
||||
mutations: {
|
||||
IgnoreUser: ({variables}) => ({
|
||||
updateQueries: {
|
||||
CoralEmbedStream_Embed: (previousData) => {
|
||||
CoralEmbedStream_Embed: (previousData, {mutationResult: {data: {ignoreUser}}}) => {
|
||||
if (get(ignoreUser, 'errors.length')) {
|
||||
return previousData;
|
||||
}
|
||||
|
||||
const ignoredUserId = variables.id;
|
||||
const updated = update(previousData, {me: {ignoredUsers: {$push: [{
|
||||
id: ignoredUserId,
|
||||
|
||||
Reference in New Issue
Block a user