Commit 89da45f9 authored by Viktor De Pasquale's avatar Viktor De Pasquale

Fixed state not being propagated correctly on startup

parent 34a0a00e
......@@ -129,6 +129,14 @@ object UpdateChannelUrl : SettingsItem.Input() {
notifyChange(BR.result)
}
init {
updateState()
}
fun updateState() {
isEnabled = UpdateChannel.value == Config.Value.CUSTOM_CHANNEL
}
override fun getView(context: Context) = DialogSettingsUpdateChannelBinding
.inflate(LayoutInflater.from(context)).also { it.data = this }.root
}
......
......@@ -9,7 +9,6 @@ import androidx.databinding.Bindable
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.topjohnwu.magisk.BR
import com.topjohnwu.magisk.Config
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.model.entity.recycler.ObservableItem
import com.topjohnwu.magisk.model.events.DieEvent
......@@ -49,19 +48,15 @@ class SettingsViewModel : CompatViewModel(), SettingsItem.Callback {
// use only instances you want, don't declare everything
is Theme -> Navigation.theme().publish()
is Redesign -> DieEvent().publish()
is UpdateChannel -> item.openUrlIfNecessary(view)
is UpdateChannel -> openUrlIfNecessary(view)
else -> Unit
}
private fun UpdateChannel.openUrlIfNecessary(view: View) {
if (value == Config.Value.CUSTOM_CHANNEL) {
private fun openUrlIfNecessary(view: View) {
UpdateChannelUrl.updateState()
if (UpdateChannelUrl.value.isBlank()) {
UpdateChannelUrl.onPressed(view, this@SettingsViewModel)
}
UpdateChannelUrl.isEnabled = true
} else {
UpdateChannelUrl.isEnabled = false
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment