From 1fae77b38fe9d0f50136fb3095075d8fd653d30c Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sun, 4 Feb 2018 10:35:24 -0800 Subject: [PATCH] refactor out StatusContent.html --- routes/_components/status/Status.html | 97 +---------------- routes/_components/status/StatusContent.html | 103 +++++++++++++++++++ 2 files changed, 107 insertions(+), 93 deletions(-) create mode 100644 routes/_components/status/StatusContent.html diff --git a/routes/_components/status/Status.html b/routes/_components/status/Status.html index ab77d294..17d948ff 100644 --- a/routes/_components/status/Status.html +++ b/routes/_components/status/Status.html @@ -16,9 +16,7 @@ {{/if}} {{#if !originalStatus.spoiler_text || spoilerShown}} -
- {{{emojifiedContent}}} -
+ {{/if}} {{#if originalMediaAttachments && originalMediaAttachments.length}} store, computed: { @@ -145,23 +108,6 @@ originalAccount: (originalStatus) => originalStatus.account, originalMediaAttachments: (originalStatus) => originalStatus.media_attachments, statusId: (originalStatus) => originalStatus.id, - emojifiedContent: (originalStatus, $autoplayGifs) => { - let status = originalStatus - let content = status.content - if (status.emojis && status.emojis.length) { - for (let emoji of status.emojis) { - let { shortcode, url, url_static } = emoji - let urlToUse = $autoplayGifs ? url : url_static - let shortcodeWithColons = `:${shortcode}:` - content = replaceAll( - content, - shortcodeWithColons, - `${shortcodeWithColons}` - ) - } - } - return content - }, spoilerShown: ($spoilersShown, $currentInstance, statusId) => $spoilersShown && $spoilersShown[$currentInstance] && $spoilersShown[$currentInstance][statusId] }, methods: { @@ -174,42 +120,7 @@ } $spoilersShown[instanceName][statusId] = !$spoilersShown[instanceName][statusId] this.store.set({'spoilersShown': $spoilersShown}) - this.hydrateContent() this.fire('recalculateHeight') - }, - hydrateContent() { - if (!this.refs.contentNode) { - return - } - let status = this.get('originalStatus') - mark('hydrateContent') - if (status.tags && status.tags.length) { - let anchorTags = Array.from(this.refs.contentNode.querySelectorAll( - 'a[class~=hashtag][href^=http]')) - for (let tag of status.tags) { - for (let anchorTag of anchorTags) { - if (anchorTag.getAttribute('href').endsWith(`/tags/${tag.name}`)) { - anchorTag.setAttribute('href', `/tags/${tag.name}`) - anchorTag.removeAttribute('target') - anchorTag.removeAttribute('rel') - } - } - } - } - 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') } } } diff --git a/routes/_components/status/StatusContent.html b/routes/_components/status/StatusContent.html new file mode 100644 index 00000000..e088d151 --- /dev/null +++ b/routes/_components/status/StatusContent.html @@ -0,0 +1,103 @@ +
+ {{{emojifiedContent}}} +
+ + \ No newline at end of file