mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 14:27:24 +00:00
Fix flow listening in SettingsController
Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
b9d2ca2517
commit
f7786e1b93
@ -101,7 +101,9 @@ import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import net.orange_box.storebox.listeners.OnPreferenceValueChangedListener
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.RequestBody
|
||||
@ -147,16 +149,13 @@ class SettingsController : NewBaseController(R.layout.controller_settings) {
|
||||
get() =
|
||||
resources!!.getString(R.string.nc_settings)
|
||||
|
||||
private fun getCurrentUser() {
|
||||
scope.launch {
|
||||
currentUserProvider.currentUser.collect {
|
||||
Log.e(TAG, "User: $it")
|
||||
this@SettingsController.currentUser = it
|
||||
this@SettingsController.credentials =
|
||||
private suspend fun getCurrentUser() {
|
||||
val user = currentUserProvider.currentUser.first()
|
||||
Log.e(TAG, "User: $user")
|
||||
currentUser = user
|
||||
credentials =
|
||||
ApiUtils.getCredentials(currentUser!!.username, currentUser!!.token)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewBound(view: View) {
|
||||
super.onViewBound(view)
|
||||
@ -164,6 +163,8 @@ class SettingsController : NewBaseController(R.layout.controller_settings) {
|
||||
sharedApplication!!.componentApplication.inject(this)
|
||||
|
||||
ViewCompat.setTransitionName((binding.avatarImage), "userAvatar.transitionTag")
|
||||
|
||||
runBlocking {
|
||||
getCurrentUser()
|
||||
|
||||
if (saveStateHandler == null) {
|
||||
@ -202,6 +203,7 @@ class SettingsController : NewBaseController(R.layout.controller_settings) {
|
||||
|
||||
setupClientCertView()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupPhoneBookIntegration() {
|
||||
scope.launch {
|
||||
@ -484,6 +486,9 @@ class SettingsController : NewBaseController(R.layout.controller_settings) {
|
||||
super.onAttach(view)
|
||||
actionBar?.show()
|
||||
dispose(null)
|
||||
|
||||
runBlocking {
|
||||
|
||||
getCurrentUser()
|
||||
|
||||
binding.settingsVersion.setOnClickListener {
|
||||
@ -548,6 +553,7 @@ class SettingsController : NewBaseController(R.layout.controller_settings) {
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupProxyTypeSettings() {
|
||||
if (("No proxy" == appPreferences!!.proxyType) || appPreferences!!.proxyType == null) {
|
||||
|
@ -38,8 +38,8 @@ class PushConfigurationConverter {
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun fromStringToPushConfiguration(value: String): PushConfigurationState? {
|
||||
if (value.isBlank()) {
|
||||
fun fromStringToPushConfiguration(value: String?): PushConfigurationState? {
|
||||
if (value.isNullOrBlank()) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user