From 45180d406927185ea287049cf4a1fe3aa395bffb Mon Sep 17 00:00:00 2001 From: eugenijm Date: Thu, 12 Nov 2020 06:16:41 +0300 Subject: [PATCH] Added the NSFW alert to the link preview. --- CHANGELOG.md | 3 ++- src/components/link-preview/link-preview.js | 15 +++++++++++++-- src/components/link-preview/link-preview.vue | 17 +++++++++++------ src/i18n/en.json | 5 +++-- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87123ddc..3242d860 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Proper handling of deletes when using websocket streaming - Added optimistic chat message sending, so you can start writing next message before the previous one has been sent - Added a small red badge to the favicon when there's unread notifications +- Added the NSFW alert to link previews ### Fixed - Fixed clicking NSFW hider through status popover @@ -45,7 +46,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [2.1.2] - 2020-09-17 ### Fixed - Fixed chats list not updating its order when new messages come in -- Fixed chat messages sometimes getting lost when you receive a message at the same time +- Fixed chat messages sometimes getting lost when you receive a message at the same time ## [2.1.1] - 2020-09-08 diff --git a/src/components/link-preview/link-preview.js b/src/components/link-preview/link-preview.js index 444aafbe..add7c563 100644 --- a/src/components/link-preview/link-preview.js +++ b/src/components/link-preview/link-preview.js @@ -1,3 +1,5 @@ +import { mapGetters } from 'vuex' + const LinkPreview = { name: 'LinkPreview', props: [ @@ -15,11 +17,20 @@ const LinkPreview = { // Currently BE shoudn't give cards if tagged NSFW, this is a bit paranoid // as it makes sure to hide the image if somehow NSFW tagged preview can // exist. - return this.card.image && !this.nsfw && this.size !== 'hide' + return this.card.image && !this.censored && this.size !== 'hide' + }, + censored () { + return this.nsfw && this.hideNsfwConfig }, useDescription () { return this.card.description && /\S/.test(this.card.description) - } + }, + hideNsfwConfig () { + return this.mergedConfig.hideNsfw + }, + ...mapGetters([ + 'mergedConfig' + ]) }, created () { if (this.useImage) { diff --git a/src/components/link-preview/link-preview.vue b/src/components/link-preview/link-preview.vue index 69171977..d3ca39b8 100644 --- a/src/components/link-preview/link-preview.vue +++ b/src/components/link-preview/link-preview.vue @@ -9,12 +9,17 @@
- {{ card.provider_name }} + + {{ $t('status.nsfw') }} + {{ card.provider_name }} +

{{ card.title }}