Featured comments error in permalink view, handling permaview moderation and handling replies moderation

This commit is contained in:
Belen Curcio
2017-09-08 17:05:20 -03:00
parent f33c31c70e
commit 2cbd59b4b5
6 changed files with 68 additions and 86 deletions
@@ -49,36 +49,39 @@ export default {
AddTag: ({variables}) => ({
updateQueries: {
CoralEmbedStream_Embed: (previous) => {
let updated = previous;
if (variables.name !== 'FEATURED') {
return;
}
const comment = findCommentInEmbedQuery(previous, variables.id);
const updated = update(previous, {
asset: {
comments: {
nodes: {
$apply: (nodes) => nodes.map((node) => {
if (node.id === variables.id) {
node.status = 'ACCEPTED';
}
return node;
})
}
},
featuredComments: {
nodes: {
$apply: (nodes) => prependNewNodes(nodes, [comment]),
}
},
featuredCommentsCount: {
$apply: (value) => value + 1
if (previous.asset.comments) {
updated = update(previous, {
asset: {
comments: {
nodes: {
$apply: (nodes) => nodes.map((node) => {
if (node.id === variables.id) {
node.status = 'ACCEPTED';
}
return node;
})
}
},
featuredComments: {
nodes: {
$apply: (nodes) => prependNewNodes(nodes, [comment]),
}
},
featuredCommentsCount: {
$apply: (value) => value + 1
},
}
}
});
});
}
return updated;
},
@@ -87,24 +90,27 @@ export default {
RemoveTag: ({variables}) => ({
updateQueries: {
CoralEmbedStream_Embed: (previous) => {
let updated = previous;
if (variables.name !== 'FEATURED') {
return;
}
const updated = update(previous, {
asset: {
featuredComments: {
nodes: {
$apply: (nodes) =>
nodes.filter((n) => n.id !== variables.id)
if (previous.asset.comments) {
updated = update(previous, {
asset: {
featuredComments: {
nodes: {
$apply: (nodes) =>
nodes.filter((n) => n.id !== variables.id)
}
},
featuredCommentsCount: {
$apply: (value) => value - 1
}
},
featuredCommentsCount: {
$apply: (value) => value - 1
}
}
});
});
}
return updated;
},