Missing file
Signed-off-by: Dominic Fischer <dominicfischer7@gmail.com>
This commit is contained in:
parent
7fbe485603
commit
1e58767374
|
@ -24,9 +24,8 @@ import im.vector.app.core.pushers.PushersManager
|
||||||
import im.vector.app.core.resources.StringProvider
|
import im.vector.app.core.resources.StringProvider
|
||||||
import im.vector.app.features.settings.troubleshoot.TroubleshootTest
|
import im.vector.app.features.settings.troubleshoot.TroubleshootTest
|
||||||
import im.vector.app.push.fcm.FcmHelper
|
import im.vector.app.push.fcm.FcmHelper
|
||||||
import org.matrix.android.sdk.api.MatrixCallback
|
|
||||||
import org.matrix.android.sdk.api.session.pushers.PushGatewayFailure
|
import org.matrix.android.sdk.api.session.pushers.PushGatewayFailure
|
||||||
import org.matrix.android.sdk.api.util.Cancelable
|
import kotlinx.coroutines.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,29 +37,31 @@ class TestPushFromPushGateway @Inject constructor(private val context: AppCompat
|
||||||
private val pushersManager: PushersManager)
|
private val pushersManager: PushersManager)
|
||||||
: TroubleshootTest(R.string.settings_troubleshoot_test_push_loop_title) {
|
: TroubleshootTest(R.string.settings_troubleshoot_test_push_loop_title) {
|
||||||
|
|
||||||
private var action: Cancelable? = null
|
private var action: Job? = null
|
||||||
|
|
||||||
override fun perform(activityResultLauncher: ActivityResultLauncher<Intent>) {
|
override fun perform(activityResultLauncher: ActivityResultLauncher<Intent>) {
|
||||||
val fcmToken = FcmHelper.getFcmToken(context) ?: run {
|
val fcmToken = FcmHelper.getFcmToken(context) ?: run {
|
||||||
status = TestStatus.FAILED
|
status = TestStatus.FAILED
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
action = pushersManager.testPush(fcmToken, object : MatrixCallback<Unit> {
|
action = GlobalScope.launch {
|
||||||
override fun onFailure(failure: Throwable) {
|
runCatching { pushersManager.testPush(fcmToken) }
|
||||||
description = if (failure is PushGatewayFailure.PusherRejected) {
|
.fold(
|
||||||
stringProvider.getString(R.string.settings_troubleshoot_test_push_loop_failed)
|
{
|
||||||
} else {
|
|
||||||
errorFormatter.toHumanReadable(failure)
|
|
||||||
}
|
|
||||||
status = TestStatus.FAILED
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSuccess(data: Unit) {
|
|
||||||
// Wait for the push to be received
|
// Wait for the push to be received
|
||||||
description = stringProvider.getString(R.string.settings_troubleshoot_test_push_loop_waiting_for_push)
|
description = stringProvider.getString(R.string.settings_troubleshoot_test_push_loop_waiting_for_push)
|
||||||
status = TestStatus.RUNNING
|
status = TestStatus.RUNNING
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description = if (failure is PushGatewayFailure.PusherRejected) {
|
||||||
|
stringProvider.getString(R.string.settings_troubleshoot_test_push_loop_failed)
|
||||||
|
} else {
|
||||||
|
errorFormatter.toHumanReadable(it)
|
||||||
|
}
|
||||||
|
status = TestStatus.FAILED
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPushReceived() {
|
override fun onPushReceived() {
|
||||||
|
@ -69,6 +70,6 @@ class TestPushFromPushGateway @Inject constructor(private val context: AppCompat
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun cancel() {
|
override fun cancel() {
|
||||||
action?.cancel()
|
job?.cancel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue