Fix duplicated re-register UP distributor call

Second call is unnecessary, and can cause issues in the distributor:
https://github.com/binwiederhier/ntfy/issues/230

Change-Id: I53f8ea38b424e8b4cc27b76001cd182429fa9439
This commit is contained in:
SpiritCroc 2022-05-22 13:28:13 +02:00
parent 8a1da1c02f
commit 93b9facbd2

View File

@ -155,7 +155,7 @@ class VectorSettingsNotificationPreferenceFragment @Inject constructor(
updateEnabledForDevice(false)
UPHelper.registerUnifiedPush(requireContext(), forceShowSelection = true) {
lifecycleScope.launch {
updateEnabledForDevice(true)
updateEnabledForDevice(true, reRegister = false)
}
Handler(Looper.getMainLooper()).postDelayed({ refreshBackgroundSyncPrefs() }, 500)
}
@ -391,9 +391,12 @@ class VectorSettingsNotificationPreferenceFragment @Inject constructor(
}
}
private suspend fun updateEnabledForDevice(enabled: Boolean) {
private suspend fun updateEnabledForDevice(enabled: Boolean, reRegister: Boolean = true) {
val pref = findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY)
pref?.isChecked = enabled
if (!reRegister) {
return
}
if (enabled) {
UPHelper.registerUnifiedPush(requireContext())
} else {