Refactor status showing/hiding code for better handling of edge cases and easier comprehension

This commit is contained in:
xenofem 2020-02-24 18:10:15 -05:00
parent d19c64314f
commit 7fa5eb07dd

View file

@ -188,23 +188,22 @@ const Status = {
} }
return this.status.attentions.length > 0 return this.status.attentions.length > 0
}, },
// When a status has a subject and is also tall, we should only have one show more/less button. If the default is to collapse statuses with subjects, we just treat it like a status with a subject; otherwise, we just treat it like a tall status.
mightHideBecauseSubject () {
return this.status.summary && (!this.tallStatus || this.localCollapseSubjectDefault)
},
mightHideBecauseTall () {
return this.tallStatus && (!this.status.summary || !this.localCollapseSubjectDefault)
},
hideSubjectStatus () { hideSubjectStatus () {
if (this.tallStatus && !this.localCollapseSubjectDefault) { return this.mightHideBecauseSubject && !this.expandingSubject
return false
}
return !this.expandingSubject && this.status.summary
}, },
hideTallStatus () { hideTallStatus () {
if (this.status.summary && this.localCollapseSubjectDefault) { return this.mightHideBecauseTall && !this.showingTall
return false
}
if (this.showingTall) {
return false
}
return this.tallStatus
}, },
showingMore () { showingMore () {
return (this.tallStatus && this.showingTall) || (this.status.summary && this.expandingSubject) return (this.mightHideBecauseTall && this.showingTall) || (this.mightHideBecauseSubject && this.expandingSubject)
}, },
nsfwClickthrough () { nsfwClickthrough () {
if (!this.status.nsfw) { if (!this.status.nsfw) {
@ -408,14 +407,10 @@ const Status = {
this.userExpanded = !this.userExpanded this.userExpanded = !this.userExpanded
}, },
toggleShowMore () { toggleShowMore () {
if (this.showingTall) { if (this.mightHideBecauseTall) {
this.showingTall = false this.showingTall = !this.showingTall
} else if (this.expandingSubject && this.status.summary) { } else if (this.mightHideBecauseSubject) {
this.expandingSubject = false this.expandingSubject = !this.expandingSubject
} else if (this.hideTallStatus) {
this.showingTall = true
} else if (this.hideSubjectStatus && this.status.summary) {
this.expandingSubject = true
} }
}, },
generateUserProfileLink (id, name) { generateUserProfileLink (id, name) {