Improve API, to avoid ignoring errors

This commit is contained in:
Benoit Marty 2024-05-06 23:06:25 +02:00 committed by Benoit Marty
parent d88ef8769e
commit a65c290dd3
18 changed files with 143 additions and 107 deletions

View file

@ -36,6 +36,7 @@ import io.element.android.libraries.matrix.api.verification.SessionVerifiedStatu
import io.element.android.libraries.push.api.PushService
import io.element.android.services.analytics.api.AnalyticsService
import kotlinx.coroutines.flow.map
import timber.log.Timber
import javax.inject.Inject
class LoggedInPresenter @Inject constructor(
@ -56,7 +57,7 @@ class LoggedInPresenter @Inject constructor(
if (isVerified) {
// Ensure pusher is registered
val currentPushProvider = pushService.getCurrentPushProvider()
if (currentPushProvider == null) {
val result = if (currentPushProvider == null) {
// Register with the first available push provider
val pushProvider = pushService.getAvailablePushProviders().firstOrNull() ?: return@LaunchedEffect
val distributor = pushProvider.getDistributors().firstOrNull() ?: return@LaunchedEffect
@ -72,6 +73,9 @@ class LoggedInPresenter @Inject constructor(
pushService.registerWith(matrixClient, currentPushProvider, currentPushDistributor)
}
}
result.onFailure {
Timber.e(it, "Failed to register pusher")
}
}
}