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

@ -253,8 +253,13 @@ export default class DelegateController {
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') && Utils.isStrUsable(publishedVersion, 'thumbnail.location') &&
publishedVersion.thumbnail.location !== proposedVersion.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')
} }
@ -281,8 +286,13 @@ export default class DelegateController {
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') && Utils.isStrUsable(publishedVersion, 'cover.location') &&
publishedVersion.cover.location !== proposedVersion.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')
} }