logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git
commit: a258182522e85c31fe9dfbfbddf7a314ca36d0ca
parent c6831a381033fa160fba95fa88b1179d3c670d9d
Author: Henry Jameson <me@hjkos.com>
Date:   Tue, 22 Jun 2021 20:16:26 +0300

fix non-notifying mentions and original mention display

Diffstat:

Msrc/components/mention_link/mention_link.vue3++-
Msrc/components/rich_content/rich_content.jsx12++++++++++--
Msrc/components/status_body/status_body.js14++++++++++++++
Msrc/components/status_body/status_body.vue3++-
4 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/components/mention_link/mention_link.vue b/src/components/mention_link/mention_link.vue @@ -5,8 +5,9 @@ <!-- eslint-disable vue/no-v-html --> <a v-if="!user" - href="url" + :href="url" class="original" + target="_blank" v-html="content" /> <!-- eslint-enable vue/no-v-html --> diff --git a/src/components/rich_content/rich_content.jsx b/src/components/rich_content/rich_content.jsx @@ -36,6 +36,10 @@ export default Vue.component('RichContent', { required: true, type: String }, + attentions: { + required: false, + default: () => [] + }, // Emoji object, as in status.emojis, note the "s" at the end... emoji: { required: true, @@ -91,8 +95,12 @@ export default Vue.component('RichContent', { </a> } - const renderMention = (attrs, children, encounteredText) => { + const renderMention = (attrs, children) => { const linkData = getLinkData(attrs, children, mentionIndex++) + linkData.notifying = this.attentions.some(a => a.statusnet_profile_url === linkData.url) + if (!linkData.notifying) { + encounteredText = true + } writtenMentions.push(linkData) if (!encounteredText) { firstMentions.push(linkData) @@ -148,7 +156,7 @@ export default Vue.component('RichContent', { const Tag = getTagName(opener) const attrs = getAttrs(opener) switch (Tag) { - case 'span': // replace images with StillImage + case 'span': // Replace last mentions class with mentionsline if (attrs['class'] && attrs['class'].includes('lastMentions')) { if (firstMentions.length > 1 && lastMentions.length > 1) { break diff --git a/src/components/status_body/status_body.js b/src/components/status_body/status_body.js @@ -85,6 +85,20 @@ const StatusContent = { }) }, methods: { + onParseReady (event) { + this.$emit('parseReady', event) + const { writtenMentions } = event + writtenMentions + .filter(mention => !mention.notifying) + .forEach(mention => { + const { content, url } = mention + const cleanedString = content.replace(/<[^>]+?>/gi, '') // remove all tags + if (!cleanedString.startsWith('@')) return + const handle = cleanedString.slice(1) + const host = url.replace(/^https?:\/\//, '').replace(/\/.+?$/, '') + this.$store.dispatch('fetchUserIfMissing', `${handle}@${host}`) + }) + }, toggleShowMore () { if (this.mightHideBecauseTall) { this.showingTall = !this.showingTall diff --git a/src/components/status_body/status_body.vue b/src/components/status_body/status_body.vue @@ -47,7 +47,8 @@ :handle-links="true" :hide-mentions="hideMentions" :greentext="mergedConfig.greentext" - @parseReady="$emit('parseReady', $event)" + :attentions="status.attentions" + @parseReady="onParseReady" /> <button