From 0a2ce698becd39abddc85ca4263ea57a211ca052 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Fri, 19 Aug 2022 16:57:08 +0100 Subject: [PATCH] fixing default distributor not being registered on login - we were saving the default distributor before asking the user, which meant when the user selected the same option it was skipped from being registered - only unregisters during the force flow, otherwise we'll crash due to no app being registered --- .../app/core/pushers/UnifiedPushHelper.kt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 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 1f44ab3686..0993485471 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 @@ -92,8 +92,6 @@ class UnifiedPushHelper @Inject constructor( return@launch } - // By default, use internal solution (fcm/background sync) - UnifiedPush.saveDistributor(context, context.packageName) val distributors = UnifiedPush.getDistributors(context) if (distributors.size == 1 && !force) { @@ -101,7 +99,14 @@ class UnifiedPushHelper @Inject constructor( UnifiedPush.registerApp(context) onDoneRunnable?.run() } else { - openDistributorDialogInternal(activity, pushersManager, onDoneRunnable, distributors, !force, !force) + openDistributorDialogInternal( + activity = activity, + pushersManager = pushersManager, + onDoneRunnable = onDoneRunnable, + distributors = distributors, + unregisterFirst = force, + cancellable = !force + ) } } } @@ -165,6 +170,12 @@ class UnifiedPushHelper @Inject constructor( onDoneRunnable?.run() } } + .setOnCancelListener { + // By default, use internal solution (fcm/background sync) + UnifiedPush.saveDistributor(context, context.packageName) + UnifiedPush.registerApp(context) + onDoneRunnable?.run() + } .setCancelable(cancellable) .show() }