Fix controlled status display toggles

This commit is contained in:
Tusooa Zhu 2021-09-09 00:03:10 -04:00
parent 59a2f65a33
commit 708633d6b1
No known key found for this signature in database
GPG key ID: 7B467EDE43A08224
3 changed files with 17 additions and 13 deletions

View file

@ -25,14 +25,16 @@ const StatusContent = {
'focused', 'focused',
'noHeading', 'noHeading',
'fullContent', 'fullContent',
'singleLine' 'singleLine',
'showingTall',
'expandingSubject',
'showingLongSubject',
'toggleShowingTall',
'toggleExpandingSubject',
'toggleShowingLongSubject'
], ],
data () { data () {
return { return {
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,
postLength: this.status.text.length, postLength: this.status.text.length,
parseReadyDone: false parseReadyDone: false
} }
@ -113,9 +115,9 @@ const StatusContent = {
}, },
toggleShowMore () { toggleShowMore () {
if (this.mightHideBecauseTall) { if (this.mightHideBecauseTall) {
this.showingTall = !this.showingTall this.toggleShowingTall()
} else if (this.mightHideBecauseSubject) { } else if (this.mightHideBecauseSubject) {
this.expandingSubject = !this.expandingSubject this.toggleExpandingSubject()
} }
}, },
generateTagLink (tag) { generateTagLink (tag) {

View file

@ -134,12 +134,8 @@ const StatusContent = {
toggleExpandingSubject () { toggleExpandingSubject () {
controlledOrUncontrolledToggle(this, 'expandingSubject') controlledOrUncontrolledToggle(this, 'expandingSubject')
}, },
toggleShowMore () { toggleShowingLongSubject () {
if (this.mightHideBecauseTall) { controlledOrUncontrolledToggle(this, 'showingLongSubject')
this.toggleShowingTall()
} else if (this.mightHideBecauseSubject) {
this.toggleExpandingSubject()
}
}, },
setMedia () { setMedia () {
const attachments = this.attachmentSize === 'hide' ? this.status.attachments : this.galleryAttachments const attachments = this.attachmentSize === 'hide' ? this.status.attachments : this.galleryAttachments

View file

@ -4,6 +4,12 @@
<StatusBody <StatusBody
:status="status" :status="status"
:single-line="singleLine" :single-line="singleLine"
:showing-tall="showingTall"
:expanding-subject="expandingSubject"
:showing-long-subject="showingLongSubject"
:toggle-showing-tall="toggleShowingTall"
:toggle-expanding-subject="toggleExpandingSubject"
:toggle-showing-long-subject="toggleShowingLongSubject"
@parseReady="$emit('parseReady', $event)" @parseReady="$emit('parseReady', $event)"
> >
<div v-if="status.poll && status.poll.options"> <div v-if="status.poll && status.poll.options">