From 0bf8bcf1c663dbe9e34f9ecc5ad41fed7095d266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Fri, 22 Nov 2019 16:21:48 +0100 Subject: [PATCH] Change watch to apollo reports update --- webapp/pages/moderation/index.vue | 83 ++++++++++++++----------------- 1 file changed, 38 insertions(+), 45 deletions(-) diff --git a/webapp/pages/moderation/index.vue b/webapp/pages/moderation/index.vue index 9478bd886..0efd2ee56 100644 --- a/webapp/pages/moderation/index.vue +++ b/webapp/pages/moderation/index.vue @@ -204,48 +204,6 @@ export default { } }, }, - watch: { - reports: { - immediate: true, - handler(newReports) { - // Wolle console.log('newReports: ', newReports) - const newReportedContentStructure = [] - newReports.forEach(report => { - const resource = - report.type === 'User' - ? report.user - : report.type === 'Post' - ? report.post - : report.type === 'Comment' - ? report.comment - : undefined - let idx = newReportedContentStructure.findIndex( - content => content.resource.id === resource.id, - ) - // if content not in content list, then add it - if (idx === -1) { - idx = newReportedContentStructure.length - newReportedContentStructure.push({ - claimId: report.claimId, - claimUpdatedAt: report.claimUpdatedAt, - claimDisable: report.claimDisable, - claimClosed: report.claimClosed, - type: report.type, - resource, - user: report.user, - post: report.post, - comment: report.comment, - contentBelongsToUser: report.type === 'User' ? null : resource.author, - reports: [], - }) - } - newReportedContentStructure[idx].reports.push(report) - }) - // Wolle console.log('newReportedContentStructure: ', newReportedContentStructure) - this.reportedContentStructure = newReportedContentStructure - }, - }, - }, methods: { confirm(content) { this.openModal(content) @@ -315,9 +273,44 @@ export default { variables() { return {} }, - // Wolle update({ Post }) { - // this.setCurrentPosts(Post) - // }, + update({ reports }) { + // Wolle console.log('reports: ', reports) + const newReportedContentStructure = [] + reports.forEach(report => { + const resource = + report.type === 'User' + ? report.user + : report.type === 'Post' + ? report.post + : report.type === 'Comment' + ? report.comment + : undefined + let idx = newReportedContentStructure.findIndex( + content => content.resource.id === resource.id, + ) + // if content not in content list, then add it + if (idx === -1) { + idx = newReportedContentStructure.length + newReportedContentStructure.push({ + claimId: report.claimId, + claimUpdatedAt: report.claimUpdatedAt, + claimDisable: report.claimDisable, + claimClosed: report.claimClosed, + type: report.type, + resource, + user: report.user, + post: report.post, + comment: report.comment, + contentBelongsToUser: report.type === 'User' ? null : resource.author, + reports: [], + }) + } + newReportedContentStructure[idx].reports.push(report) + }) + // Wolle console.log('newReportedContentStructure: ', newReportedContentStructure) + this.reportedContentStructure = newReportedContentStructure + return reports + }, fetchPolicy: 'cache-and-network', }, },