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
This commit is contained in:
Adam Brown 2022-08-19 16:57:08 +01:00
parent a251002808
commit 0a2ce698be
1 changed files with 14 additions and 3 deletions

View File

@ -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()
}