mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-19 07:51:21 +02:00
Only register for endpoints if it has changed from the one in memory
This commit is contained in:
@@ -22,7 +22,6 @@ package com.vitorpamplona.amethyst.service.notifications
|
|||||||
|
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.util.LruCache
|
import android.util.LruCache
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
@@ -83,14 +82,18 @@ class PushMessageReceiver : MessagingReceiver() {
|
|||||||
endpoint: String,
|
endpoint: String,
|
||||||
instance: String,
|
instance: String,
|
||||||
) {
|
) {
|
||||||
Log.d(TAG, "New endpoint provided:- $endpoint for Instance: $instance")
|
|
||||||
val sanitizedEndpoint = endpoint.dropLast(5)
|
val sanitizedEndpoint = endpoint.dropLast(5)
|
||||||
|
if (sanitizedEndpoint != pushHandler.getSavedEndpoint()) {
|
||||||
|
Log.d(TAG, "New endpoint provided:- $endpoint for Instance: $instance ${pushHandler.getSavedEndpoint()} $sanitizedEndpoint")
|
||||||
pushHandler.setEndpoint(sanitizedEndpoint)
|
pushHandler.setEndpoint(sanitizedEndpoint)
|
||||||
scope.launch(Dispatchers.IO) {
|
scope.launch(Dispatchers.IO) {
|
||||||
RegisterAccounts(LocalPreferences.allSavedAccounts()).go(sanitizedEndpoint)
|
RegisterAccounts(LocalPreferences.allSavedAccounts()).go(sanitizedEndpoint)
|
||||||
notificationManager().getOrCreateZapChannel(appContext)
|
notificationManager().getOrCreateZapChannel(appContext)
|
||||||
notificationManager().getOrCreateDMChannel(appContext)
|
notificationManager().getOrCreateDMChannel(appContext)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "Same endpoint provided:- $endpoint for Instance: $instance $sanitizedEndpoint")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRegistrationFailed(
|
override fun onRegistrationFailed(
|
||||||
|
Reference in New Issue
Block a user