App crashes on "troubleshoot notifications" button (#3187)
This commit is contained in:
parent
c08868bc3c
commit
9fc00fe6ff
|
@ -3,6 +3,7 @@ Changes in Element 1.1.6 (2021-04-16)
|
|||
|
||||
Bugfix 🐛:
|
||||
- Fix crash on the timeline
|
||||
- App crashes on "troubleshoot notifications" button (#3187)
|
||||
|
||||
Changes in Element 1.1.5 (2021-04-15)
|
||||
===================================================
|
||||
|
|
|
@ -24,9 +24,11 @@ import im.vector.app.core.pushers.PushersManager
|
|||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.features.settings.troubleshoot.TroubleshootTest
|
||||
import im.vector.app.push.fcm.FcmHelper
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.matrix.android.sdk.api.session.pushers.PushGatewayFailure
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -47,22 +49,26 @@ class TestPushFromPushGateway @Inject constructor(private val context: AppCompat
|
|||
return
|
||||
}
|
||||
action = GlobalScope.launch {
|
||||
status = runCatching { pushersManager.testPush(fcmToken) }
|
||||
.fold(
|
||||
{
|
||||
// Wait for the push to be received
|
||||
description = stringProvider.getString(R.string.settings_troubleshoot_test_push_loop_waiting_for_push)
|
||||
TestStatus.RUNNING
|
||||
},
|
||||
{
|
||||
description = if (it is PushGatewayFailure.PusherRejected) {
|
||||
stringProvider.getString(R.string.settings_troubleshoot_test_push_loop_failed)
|
||||
} else {
|
||||
errorFormatter.toHumanReadable(it)
|
||||
val result = runCatching { pushersManager.testPush(fcmToken) }
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
status = result
|
||||
.fold(
|
||||
{
|
||||
// Wait for the push to be received
|
||||
description = stringProvider.getString(R.string.settings_troubleshoot_test_push_loop_waiting_for_push)
|
||||
TestStatus.RUNNING
|
||||
},
|
||||
{
|
||||
description = if (it is PushGatewayFailure.PusherRejected) {
|
||||
stringProvider.getString(R.string.settings_troubleshoot_test_push_loop_failed)
|
||||
} else {
|
||||
errorFormatter.toHumanReadable(it)
|
||||
}
|
||||
TestStatus.FAILED
|
||||
}
|
||||
TestStatus.FAILED
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,11 @@ import androidx.activity.result.ActivityResultLauncher
|
|||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.api.pushrules.RuleIds
|
||||
import org.matrix.android.sdk.api.pushrules.RuleKind
|
||||
import javax.inject.Inject
|
||||
|
@ -50,10 +53,12 @@ class TestAccountSettings @Inject constructor(private val stringProvider: String
|
|||
if (manager?.diagStatus == TestStatus.RUNNING) return // wait before all is finished
|
||||
|
||||
GlobalScope.launch {
|
||||
runCatching {
|
||||
tryOrNull {
|
||||
session.updatePushRuleEnableStatus(RuleKind.OVERRIDE, defaultRule, !defaultRule.enabled)
|
||||
}
|
||||
manager?.retry(activityResultLauncher)
|
||||
withContext(Dispatchers.Main) {
|
||||
manager?.retry(activityResultLauncher)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue