mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 03:29:28 +01:00
mitigate endless loop in case of exception
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
1c6cd78fdb
commit
0991636c6d
@ -1358,10 +1358,11 @@ class SettingsActivity :
|
|||||||
|
|
||||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||||
private fun observeReadPrivacy() {
|
private fun observeReadPrivacy() {
|
||||||
|
var exceptionCaught = false
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
var state = appPreferences.readPrivacy
|
var state = appPreferences.readPrivacy
|
||||||
readPrivacyFlow.collect { newBoolean ->
|
readPrivacyFlow.collect { newBoolean ->
|
||||||
if (state != newBoolean) {
|
if (!exceptionCaught && state != newBoolean) {
|
||||||
state = newBoolean
|
state = newBoolean
|
||||||
val booleanValue = if (newBoolean) "0" else "1"
|
val booleanValue = if (newBoolean) "0" else "1"
|
||||||
val json = "{\"key\": \"read_status_privacy\", \"value\" : $booleanValue}"
|
val json = "{\"key\": \"read_status_privacy\", \"value\" : $booleanValue}"
|
||||||
@ -1377,6 +1378,7 @@ class SettingsActivity :
|
|||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
|
exceptionCaught = true
|
||||||
appPreferences.setReadPrivacy(!newBoolean)
|
appPreferences.setReadPrivacy(!newBoolean)
|
||||||
binding.settingsReadPrivacySwitch.isChecked = !newBoolean
|
binding.settingsReadPrivacySwitch.isChecked = !newBoolean
|
||||||
}
|
}
|
||||||
@ -1394,10 +1396,11 @@ class SettingsActivity :
|
|||||||
|
|
||||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||||
private fun observeTypingStatus() {
|
private fun observeTypingStatus() {
|
||||||
|
var exceptionCaught = false
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
var state = appPreferences.typingStatus
|
var state = appPreferences.typingStatus
|
||||||
typingStatusFlow.collect { newBoolean ->
|
typingStatusFlow.collect { newBoolean ->
|
||||||
if (state != newBoolean) {
|
if (!exceptionCaught && state != newBoolean) {
|
||||||
state = newBoolean
|
state = newBoolean
|
||||||
val booleanValue = if (newBoolean) "0" else "1"
|
val booleanValue = if (newBoolean) "0" else "1"
|
||||||
val json = "{\"key\": \"typing_privacy\", \"value\" : $booleanValue}"
|
val json = "{\"key\": \"typing_privacy\", \"value\" : $booleanValue}"
|
||||||
@ -1416,6 +1419,7 @@ class SettingsActivity :
|
|||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
|
exceptionCaught = true
|
||||||
appPreferences.typingStatus = !newBoolean
|
appPreferences.typingStatus = !newBoolean
|
||||||
binding.settingsTypingStatusSwitch.isChecked = !newBoolean
|
binding.settingsTypingStatusSwitch.isChecked = !newBoolean
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user