aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2021-06-14 10:30:08 +0300
committerHenry Jameson <me@hjkos.com>2021-06-14 10:30:08 +0300
commitc21b1cf89840297a781e6adc66cc195b8741cac6 (patch)
tree7d397a0a8b792e4f5f83d80bcbb8c0b95fd2bbd1 /src
parent636dbdaba8375cb991368620419e2997df0f57a9 (diff)
do the impossible, fix the unfixable
Diffstat (limited to 'src')
-rw-r--r--src/components/rich_content/rich_content.jsx16
-rw-r--r--src/components/status_body/status_body.js12
-rw-r--r--src/components/status_body/status_body.scss2
-rw-r--r--src/components/status_body/status_body.vue31
-rw-r--r--src/components/status_content/status_content.js3
-rw-r--r--src/components/status_content/status_content.vue2
6 files changed, 27 insertions, 39 deletions
diff --git a/src/components/rich_content/rich_content.jsx b/src/components/rich_content/rich_content.jsx
index ffb36f50..4144d895 100644
--- a/src/components/rich_content/rich_content.jsx
+++ b/src/components/rich_content/rich_content.jsx
@@ -5,6 +5,7 @@ import { convertHtmlToTree } from 'src/services/html_converter/html_tree_convert
import { convertHtmlToLines } from 'src/services/html_converter/html_line_converter.service.js'
import StillImage from 'src/components/still-image/still-image.vue'
import MentionLink from 'src/components/mention_link/mention_link.vue'
+import MentionsLine from 'src/components/mentions_line/mentions_line.vue'
import './rich_content.scss'
@@ -51,6 +52,11 @@ export default Vue.component('RichContent', {
required: false,
type: Boolean,
default: false
+ },
+ hideMentions: {
+ required: false,
+ type: Boolean,
+ default: false
}
},
// NEVER EVER TOUCH DATA INSIDE RENDER
@@ -64,6 +70,7 @@ export default Vue.component('RichContent', {
// unique index for vue "tag" property
let mentionIndex = 0
let tagsIndex = 0
+ let firstMentionReplaced = false
const renderImage = (tag) => {
return <StillImage
@@ -90,7 +97,12 @@ export default Vue.component('RichContent', {
writtenMentions.push(linkData)
if (!encounteredText) {
firstMentions.push(linkData)
- return ''
+ if (!firstMentionReplaced && !this.hideMentions) {
+ firstMentionReplaced = true
+ return <MentionsLine mentions={ firstMentions } />
+ } else {
+ return ''
+ }
} else {
return <MentionLink
url={attrs.href}
@@ -143,7 +155,7 @@ export default Vue.component('RichContent', {
if (firstMentions.length > 1 && lastMentions.length > 1) {
break
} else {
- return ''
+ return !this.hideMentions ? <MentionsLine mentions={lastMentions} /> : ''
}
} else {
break
diff --git a/src/components/status_body/status_body.js b/src/components/status_body/status_body.js
index 26491e1b..9ee7a109 100644
--- a/src/components/status_body/status_body.js
+++ b/src/components/status_body/status_body.js
@@ -1,6 +1,5 @@
import fileType from 'src/services/file_type/file_type.service'
import RichContent from 'src/components/rich_content/rich_content.jsx'
-import MentionsLine from 'src/components/mentions_line/mentions_line.vue'
import { mapGetters } from 'vuex'
import { library } from '@fortawesome/fontawesome-svg-core'
import { set } from 'vue'
@@ -36,9 +35,6 @@ const StatusContent = {
showingLongSubject: false,
// not as computed because it sets the initial state which will be changed later
expandingSubject: !this.$store.getters.mergedConfig.collapseMessageWithSubject,
- headTailLinks: null,
- firstMentions: [],
- lastMentions: []
}
},
computed: {
@@ -81,8 +77,7 @@ const StatusContent = {
...mapGetters(['mergedConfig'])
},
components: {
- RichContent,
- MentionsLine
+ RichContent
},
mounted () {
this.status.attentions && this.status.attentions.forEach(attn => {
@@ -98,11 +93,6 @@ const StatusContent = {
this.expandingSubject = !this.expandingSubject
}
},
- setHeadTailLinks (headTailLinks) {
- set(this, 'headTailLinks', headTailLinks)
- set(this, 'firstMentions', headTailLinks.firstMentions)
- set(this, 'lastMentions', headTailLinks.lastMentions)
- },
generateTagLink (tag) {
return `/tag/${tag}`
}
diff --git a/src/components/status_body/status_body.scss b/src/components/status_body/status_body.scss
index 81a687f1..c7732bfe 100644
--- a/src/components/status_body/status_body.scss
+++ b/src/components/status_body/status_body.scss
@@ -62,7 +62,7 @@
overflow-y: hidden;
z-index: 1;
- .rich-content-wrapper {
+ .media-body {
min-height: 0;
mask:
linear-gradient(to top, white, transparent) bottom/100% 70px no-repeat,
diff --git a/src/components/status_body/status_body.vue b/src/components/status_body/status_body.vue
index 3dc4916c..2be46303 100644
--- a/src/components/status_body/status_body.vue
+++ b/src/components/status_body/status_body.vue
@@ -38,28 +38,17 @@
>
{{ $t("general.show_more") }}
</button>
- <span
+ <RichContent
v-if="!hideSubjectStatus && !(singleLine && status.summary_raw_html)"
- class="rich-content-wrapper"
- >
- <MentionsLine
- v-if="!hideMentions && firstMentions && firstMentions.length > 0"
- :mentions="firstMentions"
- />
- <RichContent
- :class="{ '-single-line': singleLine }"
- class="text media-body"
- :html="status.raw_html"
- :emoji="status.emojis"
- :handle-links="true"
- :greentext="mergedConfig.greentext"
- @parseReady="setHeadTailLinks"
- />
- <MentionsLine
- v-if="!hideMentions && lastMentions.length > 1 && firstMentions.length <= 1"
- :mentions="lastMentions"
- />
- </span>
+ :class="{ '-single-line': singleLine }"
+ class="text media-body"
+ :html="status.raw_html"
+ :emoji="status.emojis"
+ :handle-links="true"
+ :hide-mentions="hideMentions"
+ :greentext="mergedConfig.greentext"
+ @parseReady="$emit('parseReady', $event)"
+ />
<button
v-if="hideSubjectStatus"
diff --git a/src/components/status_content/status_content.js b/src/components/status_content/status_content.js
index 11a4974b..51895ef6 100644
--- a/src/components/status_content/status_content.js
+++ b/src/components/status_content/status_content.js
@@ -92,9 +92,6 @@ const StatusContent = {
StatusBody
},
methods: {
- setHeadTailLinks (headTailLinks) {
- this.$emit('parseReady', headTailLinks)
- },
setMedia () {
const attachments = this.attachmentSize === 'hide' ? this.status.attachments : this.galleryAttachments
return () => this.$store.dispatch('setMedia', attachments)
diff --git a/src/components/status_content/status_content.vue b/src/components/status_content/status_content.vue
index feb34d2c..2e71757d 100644
--- a/src/components/status_content/status_content.vue
+++ b/src/components/status_content/status_content.vue
@@ -5,7 +5,7 @@
:status="status"
:single-line="singleLine"
:hide-mentions="hideMentions"
- @parseReady="setHeadTailLinks"
+ @parseReady="$emit('parseReady', $event)"
>
<div v-if="status.poll && status.poll.options">
<poll :base-poll="status.poll" />