fix(Delegate): thumbnail and cover removal, logic issue

This commit is contained in:
Matthieu Bessat 2020-08-10 18:05:16 +02:00
parent 7d7083a576
commit d7841b3c47

View file

@ -252,9 +252,14 @@ export default class DelegateController {
let proposedVersion: any = res.locals.organization.proposedVersion let proposedVersion: any = res.locals.organization.proposedVersion
const publishedVersion: any = res.locals.organization.publishedVersion const publishedVersion: any = res.locals.organization.publishedVersion
if ( if (
Utils.isStrUsable(proposedVersion, 'thumbnail.location') && Utils.isStrUsable(proposedVersion, 'thumbnail.location') &&
Utils.isStrUsable(publishedVersion, 'thumbnail.location') && (
publishedVersion.thumbnail.location !== proposedVersion.thumbnail.location (
Utils.isStrUsable(publishedVersion, 'thumbnail.location') &&
publishedVersion.thumbnail.location !== proposedVersion.thumbnail.location
) ||
!Utils.isStrUsable(publishedVersion, 'thumbnail.location')
)
) { ) {
MediaService.delete(proposedVersion.thumbnail.key, 'thumbnailUpdated') MediaService.delete(proposedVersion.thumbnail.key, 'thumbnailUpdated')
} }
@ -280,9 +285,14 @@ export default class DelegateController {
let proposedVersion: any = res.locals.organization.proposedVersion let proposedVersion: any = res.locals.organization.proposedVersion
const publishedVersion: any = res.locals.organization.publishedVersion const publishedVersion: any = res.locals.organization.publishedVersion
if ( if (
Utils.isStrUsable(proposedVersion, 'cover.location') && Utils.isStrUsable(proposedVersion, 'cover.location') &&
Utils.isStrUsable(publishedVersion, 'cover.location') && (
publishedVersion.cover.location !== proposedVersion.cover.location (
Utils.isStrUsable(publishedVersion, 'cover.location') &&
publishedVersion.cover.location !== proposedVersion.cover.location
) ||
!Utils.isStrUsable(publishedVersion, 'cover.location')
)
) { ) {
MediaService.delete(proposedVersion.cover.key, 'coverUpdated') MediaService.delete(proposedVersion.cover.key, 'coverUpdated')
} }