Fix content warning state being lost after screen rotation (#1756)
* Restore compose options after rotation * Fix in ViewModel instead * Move showContentWarning change into ViewModel
This commit is contained in:
parent
f3d05f82f9
commit
386d197851
|
@ -690,7 +690,7 @@ class ComposeActivity : BaseActivity(),
|
||||||
|
|
||||||
private fun onContentWarningChanged() {
|
private fun onContentWarningChanged() {
|
||||||
val showWarning = composeContentWarningBar.isGone
|
val showWarning = composeContentWarningBar.isGone
|
||||||
viewModel.showContentWarning.value = showWarning
|
viewModel.contentWarningChanged(showWarning)
|
||||||
updateVisibleCharactersLeft()
|
updateVisibleCharactersLeft()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,8 @@ class ComposeViewModel
|
||||||
private var inReplyToId: String? = null
|
private var inReplyToId: String? = null
|
||||||
private var startingVisibility: Status.Visibility = Status.Visibility.UNKNOWN
|
private var startingVisibility: Status.Visibility = Status.Visibility.UNKNOWN
|
||||||
|
|
||||||
|
private var contentWarningStateChanged: Boolean = false
|
||||||
|
|
||||||
private val instance: MutableLiveData<InstanceEntity?> = MutableLiveData(null)
|
private val instance: MutableLiveData<InstanceEntity?> = MutableLiveData(null)
|
||||||
|
|
||||||
val instanceParams: LiveData<ComposeInstanceParams> = instance.map { instance ->
|
val instanceParams: LiveData<ComposeInstanceParams> = instance.map { instance ->
|
||||||
|
@ -198,6 +200,11 @@ class ComposeViewModel
|
||||||
return textChanged || contentWarningChanged || mediaChanged || pollChanged
|
return textChanged || contentWarningChanged || mediaChanged || pollChanged
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun contentWarningChanged(value: Boolean) {
|
||||||
|
showContentWarning.value = value
|
||||||
|
contentWarningStateChanged = true
|
||||||
|
}
|
||||||
|
|
||||||
fun deleteDraft() {
|
fun deleteDraft() {
|
||||||
saveTootHelper.deleteDraft(this.savedTootUid)
|
saveTootHelper.deleteDraft(this.savedTootUid)
|
||||||
}
|
}
|
||||||
|
@ -368,7 +375,9 @@ class ComposeViewModel
|
||||||
if (contentWarning != null) {
|
if (contentWarning != null) {
|
||||||
startingContentWarning = contentWarning
|
startingContentWarning = contentWarning
|
||||||
}
|
}
|
||||||
|
if (!contentWarningStateChanged) {
|
||||||
showContentWarning.value = !contentWarning.isNullOrBlank()
|
showContentWarning.value = !contentWarning.isNullOrBlank()
|
||||||
|
}
|
||||||
|
|
||||||
// recreate media list
|
// recreate media list
|
||||||
// when coming from SavedTootActivity
|
// when coming from SavedTootActivity
|
||||||
|
|
Loading…
Reference in New Issue