diff --git a/pages/event/_id.vue b/pages/event/_id.vue index ad79404f..c47a5b37 100644 --- a/pages/event/_id.vue +++ b/pages/event/_id.vue @@ -11,14 +11,14 @@ v-container#event.pa-0.pa-sm-2 v-row v-col.col-12.col-lg-8 //- fake image to use u-featured in h-event microformat - img.u-featured(v-show='false' v-if='event.media' :src='event | mediaURL') + img.u-featured(v-show='false' v-if='hasMedia' :src='event | mediaURL') v-img.main_image.mb-3( contain :alt='event | mediaURL("alt")' :src='event | mediaURL' :lazy-src='event | mediaURL("thumb")' - v-if='event.media && event.media.length') - .p-description.text-body-1.pa-3.grey.darken-4.rounded(v-if='!event.media && event.description' v-html='event.description') + v-if='hasMedia') + .p-description.text-body-1.pa-3.grey.darken-4.rounded(v-if='!hasMedia && event.description' v-html='event.description') v-col.col-12.col-lg-4 v-card @@ -61,11 +61,11 @@ v-container#event.pa-0.pa-sm-2 :href='`/api/event/${event.slug || event.id}.ics`') v-icon mdi-calendar-export - .p-description.text-body-1.pa-3.grey.darken-4.rounded(v-if='event.media && event.description' v-html='event.description') + .p-description.text-body-1.pa-3.grey.darken-4.rounded(v-if='hasMedia && event.description' v-html='event.description') //- resources from fediverse #resources.mt-1(v-if='settings.enable_federation') - //- div.float-right(v-if='!settings.hide_boosts') + //- div.float-right(v-if='settings.hide_boosts') //- small.mr-3 🔖 {{event.likes.length}} //- small ✊ {{event.boost.length}}
@@ -236,6 +236,9 @@ export default { }, computed: { ...mapState(['settings']), + hasMedia () { + return this.event.media && this.event.media.length + }, plainDescription () { return htmlToText.fromString(this.event.description.replace('\n', '').slice(0, 1000)) }, diff --git a/server/api/controller/event.js b/server/api/controller/event.js index 01a770ca..f833cb3b 100644 --- a/server/api/controller/event.js +++ b/server/api/controller/event.js @@ -297,13 +297,15 @@ const eventController = { url = await helpers.getImageFromURL(body.image_url) } - const focalpoint = body.image_focalpoint ? body.image_focalpoint.split(',') : [0, 0] + const focalpoint = body.image_focalpoint ? body.image_focalpoint.split(',') : ['0', '0'] eventDetails.media = [{ url, name: body.image_name || '', - focalpoint: [parseFloat(focalpoint[0]), parseFloat(focalpoint[1].toFixed(2))] + focalpoint: [parseFloat(focalpoint[0].slice(0, 6)), parseFloat(focalpoint[1].slice(0, 6))] }] + } else { + eventDetails.media = [] } const event = await Event.create(eventDetails) @@ -374,7 +376,7 @@ const eventController = { recurrent } - if ((req.file || /^https?:\/\//.test(body.image_url)) && !event.recurrent && event.media.length) { + if ((req.file || /^https?:\/\//.test(body.image_url)) && !event.recurrent && event.media && event.media.length) { const old_path = path.resolve(config.upload_path, event.media[0].url) const old_thumb_path = path.resolve(config.upload_path, 'thumb', event.media[0].url) try { @@ -395,8 +397,8 @@ const eventController = { } } - if (body.image_focalpoint) { - const focalpoint = body.image_focalpoint ? body.image_focalpoint.split(',') : [0, 0] + if (url && !event.recurrent) { + const focalpoint = body.image_focalpoint ? body.image_focalpoint.split(',') : ['0', '0'] eventDetails.media = [{ url, name: body.image_name || '', @@ -452,7 +454,12 @@ const eventController = { } const notifier = require('../../notifier') await notifier.notifyEvent('Delete', event.id) - log.debug('[EVENT REMOVED]', event.title) + + // unassociate child events + if (event.recurrent) { + await Event.update({ parentId: null }, { where: { parentId: event.id } }) + } + log.debug('[EVENT REMOVED] ' + event.title) await event.destroy() res.sendStatus(200) } else {