diff options
| author | Henry Jameson <me@hjkos.com> | 2021-08-15 02:41:53 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2021-08-15 02:41:53 +0300 |
| commit | 530ac4442b498c90c73533d2a03ae5b7d6875900 (patch) | |
| tree | 7cc984514f6d0a9a929b607f5089311dac8ee80c /src/components/status_body | |
| parent | 4465de5241a6ed148d00d20de9e348f4991a4400 (diff) | |
removed useless code, review change, fixed bug with tall statuses
Diffstat (limited to 'src/components/status_body')
| -rw-r--r-- | src/components/status_body/status_body.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/components/status_body/status_body.js b/src/components/status_body/status_body.js index 8757154d..b941765c 100644 --- a/src/components/status_body/status_body.js +++ b/src/components/status_body/status_body.js @@ -32,7 +32,8 @@ const StatusContent = { showingTall: this.fullContent || (this.inConversation && this.focused), showingLongSubject: false, // not as computed because it sets the initial state which will be changed later - expandingSubject: !this.$store.getters.mergedConfig.collapseMessageWithSubject + expandingSubject: !this.$store.getters.mergedConfig.collapseMessageWithSubject, + postLength: this.status.text.length } }, computed: { @@ -47,7 +48,7 @@ const StatusContent = { // Using max-height + overflow: auto for status components resulted in false positives // very often with japanese characters, and it was very annoying. tallStatus () { - const lengthScore = this.status.raw_html.split(/<p|<br/).length + this.status.text.length / 80 + const lengthScore = this.status.raw_html.split(/<p|<br/).length + this.postLength / 80 return lengthScore > 20 }, longSubject () { @@ -86,7 +87,7 @@ const StatusContent = { methods: { onParseReady (event) { this.$emit('parseReady', event) - const { writtenMentions } = event + const { writtenMentions, invisibleMentions } = event writtenMentions .filter(mention => !mention.notifying) .forEach(mention => { @@ -97,6 +98,15 @@ const StatusContent = { const host = url.replace(/^https?:\/\//, '').replace(/\/.+?$/, '') this.$store.dispatch('fetchUserIfMissing', `${handle}@${host}`) }) + /* This is a bit of a hack to make current tall status detector work + * with rich mentions. Invisible mentions are detected at RichContent level + * and also we generate plaintext version of mentions by stripping tags + * so here we subtract from post length by each mention that became invisible + * via MentionsLine + */ + this.postLength = invisibleMentions.reduce((acc, mention) => { + return acc - mention.textContent.length - 1 + }, this.postLength) }, toggleShowMore () { if (this.mightHideBecauseTall) { |
