hydrate status mentions
This commit is contained in:
parent
98c0defacc
commit
b83d1bac8e
|
@ -297,7 +297,7 @@
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
oncreate() {
|
oncreate() {
|
||||||
this.hashtagifyContent()
|
this.hydrateContent()
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
Avatar,
|
Avatar,
|
||||||
|
@ -342,7 +342,7 @@
|
||||||
let statusId = this.get('statusId')
|
let statusId = this.get('statusId')
|
||||||
$spoilersShown[statusId] = !$spoilersShown[statusId]
|
$spoilersShown[statusId] = !$spoilersShown[statusId]
|
||||||
this.store.set({'spoilersShown': $spoilersShown})
|
this.store.set({'spoilersShown': $spoilersShown})
|
||||||
this.hashtagifyContent()
|
this.hydrateContent()
|
||||||
this.fire('recalculateHeight')
|
this.fire('recalculateHeight')
|
||||||
},
|
},
|
||||||
onClickSensitiveMediaButton() {
|
onClickSensitiveMediaButton() {
|
||||||
|
@ -352,27 +352,39 @@
|
||||||
this.store.set({'sensitivesShown': $sensitivesShown})
|
this.store.set({'sensitivesShown': $sensitivesShown})
|
||||||
this.fire('recalculateHeight')
|
this.fire('recalculateHeight')
|
||||||
},
|
},
|
||||||
hashtagifyContent() {
|
hydrateContent() {
|
||||||
if (!this.refs.contentNode) {
|
if (!this.refs.contentNode) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let status = this.get('originalStatus')
|
let status = this.get('originalStatus')
|
||||||
mark('hydrateHashtags')
|
mark('hydrateContent')
|
||||||
if (status.tags && status.tags.length) {
|
if (status.tags && status.tags.length) {
|
||||||
let anchorTags = Array.from(this.refs.contentNode.querySelectorAll(
|
let anchorTags = Array.from(this.refs.contentNode.querySelectorAll(
|
||||||
'a[class~=hashtag][href^=http]'))
|
'a[class~=hashtag][href^=http]'))
|
||||||
for (let tag of status.tags) {
|
for (let tag of status.tags) {
|
||||||
let { name } = tag
|
|
||||||
for (let anchorTag of anchorTags) {
|
for (let anchorTag of anchorTags) {
|
||||||
if (anchorTag.getAttribute('href').endsWith(`/tags/${name}`)) {
|
if (anchorTag.getAttribute('href').endsWith(`/tags/${tag.name}`)) {
|
||||||
anchorTag.setAttribute('href', `/tags/${name}`)
|
anchorTag.setAttribute('href', `/tags/${tag.name}`)
|
||||||
anchorTag.removeAttribute('target')
|
anchorTag.removeAttribute('target')
|
||||||
anchorTag.removeAttribute('rel')
|
anchorTag.removeAttribute('rel')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stop('hydrateHashtags')
|
if (status.mentions && status.mentions.length) {
|
||||||
|
let anchorTags = Array.from(this.refs.contentNode.querySelectorAll(
|
||||||
|
'a[class~=mention][href^=http]'))
|
||||||
|
for (let mention of status.mentions) {
|
||||||
|
for (let anchorTag of anchorTags) {
|
||||||
|
if (anchorTag.getAttribute('href') === mention.url) {
|
||||||
|
anchorTag.setAttribute('href', `/accounts/${mention.id}`)
|
||||||
|
anchorTag.removeAttribute('target')
|
||||||
|
anchorTag.removeAttribute('rel')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stop('hydrateContent')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue