|
|
@ -55,27 +55,7 @@ class LoggedInPresenter @Inject constructor( |
|
|
|
|
|
|
|
|
|
|
|
LaunchedEffect(isVerified) { |
|
|
|
LaunchedEffect(isVerified) { |
|
|
|
if (isVerified) { |
|
|
|
if (isVerified) { |
|
|
|
Timber.d("Ensure pusher is registered") |
|
|
|
ensurePusherIsRegistered() |
|
|
|
val currentPushProvider = pushService.getCurrentPushProvider() |
|
|
|
|
|
|
|
val result = if (currentPushProvider == null) { |
|
|
|
|
|
|
|
Timber.d("Register with the first available push provider") |
|
|
|
|
|
|
|
val pushProvider = pushService.getAvailablePushProviders().firstOrNull() ?: return@LaunchedEffect |
|
|
|
|
|
|
|
val distributor = pushProvider.getDistributors().firstOrNull() ?: return@LaunchedEffect |
|
|
|
|
|
|
|
pushService.registerWith(matrixClient, pushProvider, distributor) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
val currentPushDistributor = currentPushProvider.getCurrentDistributor(matrixClient) |
|
|
|
|
|
|
|
if (currentPushDistributor == null) { |
|
|
|
|
|
|
|
Timber.d("Register with the first available distributor") |
|
|
|
|
|
|
|
val distributor = currentPushProvider.getDistributors().firstOrNull() ?: return@LaunchedEffect |
|
|
|
|
|
|
|
pushService.registerWith(matrixClient, currentPushProvider, distributor) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Timber.d("Re-register with the current distributor") |
|
|
|
|
|
|
|
pushService.registerWith(matrixClient, currentPushProvider, currentPushDistributor) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
result.onFailure { |
|
|
|
|
|
|
|
Timber.e(it, "Failed to register pusher") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Timber.w("Session is not verified, not registering pusher") |
|
|
|
Timber.w("Session is not verified, not registering pusher") |
|
|
|
} |
|
|
|
} |
|
|
@ -99,6 +79,33 @@ class LoggedInPresenter @Inject constructor( |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private suspend fun ensurePusherIsRegistered() { |
|
|
|
|
|
|
|
Timber.d("Ensure pusher is registered") |
|
|
|
|
|
|
|
val currentPushProvider = pushService.getCurrentPushProvider() |
|
|
|
|
|
|
|
val result = if (currentPushProvider == null) { |
|
|
|
|
|
|
|
Timber.d("Register with the first available push provider") |
|
|
|
|
|
|
|
val pushProvider = pushService.getAvailablePushProviders().firstOrNull() |
|
|
|
|
|
|
|
?: return Unit.also { Timber.w("No push provider available") } |
|
|
|
|
|
|
|
val distributor = pushProvider.getDistributors().firstOrNull() |
|
|
|
|
|
|
|
?: return Unit.also { Timber.w("No distributor available") } |
|
|
|
|
|
|
|
pushService.registerWith(matrixClient, pushProvider, distributor) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
val currentPushDistributor = currentPushProvider.getCurrentDistributor(matrixClient) |
|
|
|
|
|
|
|
if (currentPushDistributor == null) { |
|
|
|
|
|
|
|
Timber.d("Register with the first available distributor") |
|
|
|
|
|
|
|
val distributor = currentPushProvider.getDistributors().firstOrNull() |
|
|
|
|
|
|
|
?: return Unit.also { Timber.w("No distributor available") } |
|
|
|
|
|
|
|
pushService.registerWith(matrixClient, currentPushProvider, distributor) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Timber.d("Re-register with the current distributor") |
|
|
|
|
|
|
|
pushService.registerWith(matrixClient, currentPushProvider, currentPushDistributor) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
result.onFailure { |
|
|
|
|
|
|
|
Timber.e(it, "Failed to register pusher") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun reportCryptoStatusToAnalytics(verificationState: SessionVerifiedStatus, recoveryState: RecoveryState) { |
|
|
|
private fun reportCryptoStatusToAnalytics(verificationState: SessionVerifiedStatus, recoveryState: RecoveryState) { |
|
|
|
// Update first the user property, to store the current status for that posthog user |
|
|
|
// Update first the user property, to store the current status for that posthog user |
|
|
|
val userVerificationState = verificationState.toAnalyticsUserPropertyValue() |
|
|
|
val userVerificationState = verificationState.toAnalyticsUserPropertyValue() |
|
|
|