diff --git a/gulp/res/js/yous.js b/gulp/res/js/yous.js index 8e3e10d0..472b9a6a 100644 --- a/gulp/res/js/yous.js +++ b/gulp/res/js/yous.js @@ -72,22 +72,27 @@ const handleNewYous = (e) => { const notificationOptions = { body: postData.nomarkup ? postData.nomarkup.substring(0,100) : '' } - if (postData.files.length > 0 && !postData.spoiler) { + if (postData.files.length > 0) { //tries to use a thumb instead of full files, will be lighter on bandwidth and able to show for video and some audio too + let notificationImageURL; + const spoilerNotification = (postData.spoiler || postData.files.some(f => f.spoiler === true)); const notificationFile = postData.files.find(f => (!f.spoiler && (f.hasThumb === true || f.mimetype.startsWith('image/')))); - if (notificationFile) { - let notificationImageURL; - if (notificationFile.hasThumb) { - notificationImageURL = `/file/thumb/${notificationFile.hash}${notificationFile.thumbextension}`; - } else { - notificationImageURL = `/file/${notificationFile.filename}`; - } - if (notificationImageURL) { - notificationOptions.image = notificationImageURL; - notificationOptions.badge = notificationImageURL; - notificationOptions.icon = notificationImageURL; + if (spoilerNotification && !notificationFile) { + notificationImageURL = '/file/spoiler.png'; + } else { + if (notificationFile) { + if (notificationFile.hasThumb) { + notificationImageURL = `/file/thumb/${notificationFile.hash}${notificationFile.thumbextension}`; + } else { + notificationImageURL = `/file/${notificationFile.filename}`; + } } } + if (notificationImageURL) { + notificationOptions.image = notificationImageURL; + notificationOptions.badge = notificationImageURL; + notificationOptions.icon = notificationImageURL; + } } new Notification(`${quotesYou ? 'New quote in: ' : ''}${document.title}`, notificationOptions); } catch (e) {