not pretty, but it works

This commit is contained in:
Riley Davis
2017-05-03 10:20:03 -06:00
parent e60bcb9caf
commit 324e82c070
2 changed files with 28 additions and 8 deletions
@@ -54,7 +54,20 @@ export const setCommentStatus = graphql(SET_COMMENT_STATUS, {
},
updateQueries: {
ModQueue: (oldData) => {
const comment = oldData.all.find(c => c.id === commentId);
let comment = oldData.all.find(c => c.id === commentId);
if (!comment) {
comment = oldData.premod.find(c => c.id === commentId);
}
if (!comment) {
comment = oldData.flagged.find(c => c.id === commentId);
}
if (!comment) {
comment = oldData.rejected.find(c => c.id === commentId);
}
let accepted;
let acceptedCount = oldData.acceptedCount;
@@ -97,7 +110,20 @@ export const setCommentStatus = graphql(SET_COMMENT_STATUS, {
},
updateQueries: {
ModQueue: (oldData) => {
const comment = oldData.all.find(c => c.id === commentId);
let comment = oldData.all.find(c => c.id === commentId);
if (!comment) {
comment = oldData.premod.find(c => c.id === commentId);
}
if (!comment) {
comment = oldData.flagged.find(c => c.id === commentId);
}
if (!comment) {
comment = oldData.accepted.find(c => c.id === commentId);
}
let rejected;
let rejectedCount = oldData.rejectedCount;
@@ -71,12 +71,6 @@ export const loadMore = (fetchMore) => ({limit, cursor, sort, tab, asset_id}) =>
]
};
// if we're not in the all tab, put the new comments in there anyway
// this way the acceptComment and rejectComment mutations don't break
if (tab !== 'all') {
updatedData.all = [...updatedData.all, ...comments];
}
return updatedData;
}
});