test on new endpoint

This commit is contained in:
S1m 2021-07-12 18:14:46 +02:00
parent 15c3bb7fc3
commit dbfa5e1fd5

View file

@ -156,12 +156,16 @@ val upHandler = object: MessagingReceiverHandler {
override fun onNewEndpoint(context: Context?, endpoint: String, instance: String) { override fun onNewEndpoint(context: Context?, endpoint: String, instance: String) {
initVar(context!!) initVar(context!!)
Timber.i("onNewEndpoint: adding $endpoint") Timber.i("onNewEndpoint: adding $endpoint")
UPHelper.storeUpEndpoint(context, endpoint)
if (vectorPreferences.areNotificationEnabledForDevice() && activeSessionHolder.hasActiveSession()) { if (vectorPreferences.areNotificationEnabledForDevice() && activeSessionHolder.hasActiveSession()) {
val gateway = UPHelper.customOrDefaultGateway(context, endpoint) val gateway = UPHelper.customOrDefaultGateway(context, endpoint)
UPHelper.storePushGateway(context, gateway) if (UPHelper.getUpEndpoint(context) != endpoint ||
UPHelper.storeUpEndpoint(context, endpoint) UPHelper.getPushGateway(context) != gateway) {
pusherManager.registerPusher(context, endpoint, gateway) UPHelper.storePushGateway(context, gateway)
UPHelper.storeUpEndpoint(context, endpoint)
pusherManager.registerPusher(context, endpoint, gateway)
} else {
Timber.i("onNewEndpoint: skipped")
}
} }
val mode = BackgroundSyncMode.FDROID_BACKGROUND_SYNC_MODE_DISABLED val mode = BackgroundSyncMode.FDROID_BACKGROUND_SYNC_MODE_DISABLED
vectorPreferences.setFdroidSyncBackgroundMode(mode) vectorPreferences.setFdroidSyncBackgroundMode(mode)