diff --git a/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt b/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt index c81166ecd1..0c2a62c658 100644 --- a/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt @@ -1280,7 +1280,7 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu } private fun observeReadPrivacy() { - lifecycleScope.launch { + lifecycleScope.launch(Dispatchers.IO) { var state = appPreferences.readPrivacy readPrivacyFlow.collect { newBoolean -> if (state != newBoolean) { @@ -1288,15 +1288,13 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu val booleanValue = if (newBoolean) "0" else "1" val json = "{\"key\": \"read_status_privacy\", \"value\" : $booleanValue}" try { - withContext(Dispatchers.IO) { - credentials?.let { credentials -> - ncApiCoroutines.setReadStatusPrivacy( - credentials, - ApiUtils.getUrlForUserSettings(currentUser!!.baseUrl!!), - json.toRequestBody("application/json".toMediaTypeOrNull()) - ) - Log.i(TAG, "reading status set") - } + credentials?.let { credentials -> + ncApiCoroutines.setReadStatusPrivacy( + credentials, + ApiUtils.getUrlForUserSettings(currentUser!!.baseUrl!!), + json.toRequestBody("application/json".toMediaTypeOrNull()) + ) + Log.i(TAG, "reading status set") } } catch (e: Exception) { withContext(Dispatchers.Main) { @@ -1315,7 +1313,7 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu } private fun observeTypingStatus() { - lifecycleScope.launch { + lifecycleScope.launch(Dispatchers.IO) { var state = appPreferences.typingStatus typingStatusFlow.collect { newBoolean -> if (state != newBoolean) { @@ -1324,18 +1322,16 @@ class SettingsActivity : BaseActivity(), SetPhoneNumberDialogFragment.SetPhoneNu val json = "{\"key\": \"typing_privacy\", \"value\" : $booleanValue}" try { - withContext(Dispatchers.IO) { - credentials?.let { credentials -> - ncApiCoroutines.setTypingStatusPrivacy( - credentials, - ApiUtils.getUrlForUserSettings(currentUser!!.baseUrl!!), - json.toRequestBody("application/json".toMediaTypeOrNull()) - ) - } - withContext(Dispatchers.Main) { - loadCapabilitiesAndUpdateSettings() - Log.i(TAG, "typing status set") - } + credentials?.let { credentials -> + ncApiCoroutines.setTypingStatusPrivacy( + credentials, + ApiUtils.getUrlForUserSettings(currentUser!!.baseUrl!!), + json.toRequestBody("application/json".toMediaTypeOrNull()) + ) + } + withContext(Dispatchers.Main) { + loadCapabilitiesAndUpdateSettings() + Log.i(TAG, "typing status set") } } catch (e: Exception) { withContext(Dispatchers.Main) {