Return empty array instead null for "not reviewed"

@mattwr18 why did you add the null check in th resolver?
This commit is contained in:
roschaefer 2019-12-06 02:12:47 +01:00
parent 2f2bf571ed
commit fdca5b008b
3 changed files with 9 additions and 5 deletions

View File

@ -144,7 +144,6 @@ export default {
})
try {
const txResult = await readTxPromise
if (!txResult[0]) return null
reviewed = txResult.map(reportedRecord => {
const { review, moderator } = reportedRecord
const relationshipWithNestedAttributes = {

View File

@ -101,7 +101,7 @@ export const reports = [
slug: 'bigoted-post',
title: "I'm a bigoted post!",
},
reviewed: null,
reviewed: [],
},
{
__typename: 'Report',

View File

@ -40,7 +40,7 @@
<base-icon :name="statusIconName" :class="isDisabled ? '--disabled' : '--enabled'" />
{{ statusText }}
</span>
<client-only v-if="report.reviewed">
<client-only v-if="isReviewed">
<hc-user
:user="moderatorOfLatestReview"
:showAvatar="false"
@ -109,6 +109,10 @@ export default {
isDisabled() {
return this.report.resource.disabled
},
isReviewed() {
const { reviewed } = this.report
return reviewed && reviewed.length
},
iconName() {
if (this.isPost) return 'bookmark'
else if (this.isComment) return 'comments'
@ -138,12 +142,13 @@ export default {
return this.isDisabled ? 'eye-slash' : 'eye'
},
statusText() {
if (!this.report.reviewed) return this.$t('moderation.reports.enabled')
if (!this.isReviewed) return this.$t('moderation.reports.enabled')
else if (this.isDisabled) return this.$t('moderation.reports.disabledBy')
else return this.$t('moderation.reports.enabledBy')
},
moderatorOfLatestReview() {
return this.report.reviewed[0].moderator
const [latestReview] = this.report.reviewed
return latestReview && latestReview.moderator
},
},
}