From a139756dbc18a866fe05fd947dc21517dc919fed Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 2 Jun 2022 15:28:27 +0200 Subject: [PATCH] Fix an issue with empty endpoint. It can happen if the endpoint is manually removed from the distributor. --- .../java/im/vector/app/core/pushers/UnifiedPushHelper.kt | 2 +- .../settings/troubleshoot/TestUnifiedPushEndpoint.kt | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/pushers/UnifiedPushHelper.kt b/vector/src/main/java/im/vector/app/core/pushers/UnifiedPushHelper.kt index 1fd7fcaac5..558c7db911 100644 --- a/vector/src/main/java/im/vector/app/core/pushers/UnifiedPushHelper.kt +++ b/vector/src/main/java/im/vector/app/core/pushers/UnifiedPushHelper.kt @@ -253,7 +253,7 @@ class UnifiedPushHelper @Inject constructor( fun getPrivacyFriendlyUpEndpoint(): String? { val endpoint = unifiedPushStore.getEndpointOrToken() - if (endpoint.isNullOrEmpty()) return endpoint + if (endpoint.isNullOrEmpty()) return null if (isEmbeddedDistributor()) { return endpoint } diff --git a/vector/src/main/java/im/vector/app/features/settings/troubleshoot/TestUnifiedPushEndpoint.kt b/vector/src/main/java/im/vector/app/features/settings/troubleshoot/TestUnifiedPushEndpoint.kt index fefb1d6478..a29d1ad812 100644 --- a/vector/src/main/java/im/vector/app/features/settings/troubleshoot/TestUnifiedPushEndpoint.kt +++ b/vector/src/main/java/im/vector/app/features/settings/troubleshoot/TestUnifiedPushEndpoint.kt @@ -30,13 +30,10 @@ class TestUnifiedPushEndpoint @Inject constructor( override fun perform(activityResultLauncher: ActivityResultLauncher) { val endpoint = unifiedPushHelper.getPrivacyFriendlyUpEndpoint() - endpoint?.let { - description = stringProvider.getString( - R.string.settings_troubleshoot_test_current_endpoint_success, - unifiedPushHelper.getPrivacyFriendlyUpEndpoint() - ) + if (endpoint != null) { + description = stringProvider.getString(R.string.settings_troubleshoot_test_current_endpoint_success, endpoint) status = TestStatus.SUCCESS - } ?: run { + } else { description = stringProvider.getString(R.string.settings_troubleshoot_test_current_endpoint_failed) status = TestStatus.FAILED }