fix non-notifying mentions and original mention display

This commit is contained in:
Henry Jameson 2021-06-22 20:16:26 +03:00
parent c6831a3810
commit a258182522
4 changed files with 28 additions and 4 deletions

View File

@ -5,8 +5,9 @@
<!-- eslint-disable vue/no-v-html --> <!-- eslint-disable vue/no-v-html -->
<a <a
v-if="!user" v-if="!user"
href="url" :href="url"
class="original" class="original"
target="_blank"
v-html="content" v-html="content"
/> />
<!-- eslint-enable vue/no-v-html --> <!-- eslint-enable vue/no-v-html -->

View File

@ -36,6 +36,10 @@ export default Vue.component('RichContent', {
required: true, required: true,
type: String type: String
}, },
attentions: {
required: false,
default: () => []
},
// Emoji object, as in status.emojis, note the "s" at the end... // Emoji object, as in status.emojis, note the "s" at the end...
emoji: { emoji: {
required: true, required: true,
@ -91,8 +95,12 @@ export default Vue.component('RichContent', {
</a> </a>
} }
const renderMention = (attrs, children, encounteredText) => { const renderMention = (attrs, children) => {
const linkData = getLinkData(attrs, children, mentionIndex++) 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) writtenMentions.push(linkData)
if (!encounteredText) { if (!encounteredText) {
firstMentions.push(linkData) firstMentions.push(linkData)
@ -148,7 +156,7 @@ export default Vue.component('RichContent', {
const Tag = getTagName(opener) const Tag = getTagName(opener)
const attrs = getAttrs(opener) const attrs = getAttrs(opener)
switch (Tag) { switch (Tag) {
case 'span': // replace images with StillImage case 'span': // Replace last mentions class with mentionsline
if (attrs['class'] && attrs['class'].includes('lastMentions')) { if (attrs['class'] && attrs['class'].includes('lastMentions')) {
if (firstMentions.length > 1 && lastMentions.length > 1) { if (firstMentions.length > 1 && lastMentions.length > 1) {
break break

View File

@ -85,6 +85,20 @@ const StatusContent = {
}) })
}, },
methods: { 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 () { toggleShowMore () {
if (this.mightHideBecauseTall) { if (this.mightHideBecauseTall) {
this.showingTall = !this.showingTall this.showingTall = !this.showingTall

View File

@ -47,7 +47,8 @@
:handle-links="true" :handle-links="true"
:hide-mentions="hideMentions" :hide-mentions="hideMentions"
:greentext="mergedConfig.greentext" :greentext="mergedConfig.greentext"
@parseReady="$emit('parseReady', $event)" :attentions="status.attentions"
@parseReady="onParseReady"
/> />
<button <button