diff --git a/src/components/mention_link/mention_link.vue b/src/components/mention_link/mention_link.vue index e4d395fa..514b7475 100644 --- a/src/components/mention_link/mention_link.vue +++ b/src/components/mention_link/mention_link.vue @@ -5,8 +5,9 @@ diff --git a/src/components/rich_content/rich_content.jsx b/src/components/rich_content/rich_content.jsx index ce562f13..cd73f2e5 100644 --- 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', { } - 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) @@ -121,14 +129,13 @@ export default Vue.component('RichContent', { if (emptyText) { return encounteredText ? item : item.trim() } - let unescapedItem = unescape(item) if (!encounteredText) { - unescapedItem = unescapedItem.trimStart() + item = item.trimStart() encounteredText = true } if (item.includes(':')) { - unescapedItem = ['', processTextForEmoji( - unescapedItem, + item = ['', processTextForEmoji( + item, this.emoji, ({ shortcode, url }) => { return 1 && lastMentions.length > 1) { break @@ -189,7 +196,7 @@ export default Vue.component('RichContent', { const emptyText = item.trim() === '' if (emptyText) return item if (!encounteredTextReverse) encounteredTextReverse = true - return item + return unescape(item) } else if (Array.isArray(item)) { // Handle tag nodes const [opener, children] = item @@ -203,9 +210,7 @@ export default Vue.component('RichContent', { return renderHashtag(attrs, children, encounteredTextReverse) } else { attrs.target = '_blank' - html.includes('freenode') && console.log('PASS1', children) const newChildren = [...children].reverse().map(processItemReverse).reverse() - html.includes('freenode') && console.log('PASS1b', newChildren) return { newChildren } diff --git a/src/components/status_body/status_body.js b/src/components/status_body/status_body.js index 94366c6c..7ee965d9 100644 --- a/src/components/status_body/status_body.js +++ b/src/components/status_body/status_body.js @@ -86,6 +86,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 index 3eb13ce2..91ab1797 100644 --- a/src/components/status_body/status_body.vue +++ b/src/components/status_body/status_body.vue @@ -50,7 +50,8 @@ :handle-links="true" :hide-mentions="hideMentions" :greentext="mergedConfig.greentext" - @parseReady="$emit('parseReady', $event)" + :attentions="status.attentions" + @parseReady="onParseReady" />