mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-06 11:28:22 +00:00
retry registering with push server and show message if failed
reconnect with relays when changing notification type
This commit is contained in:
@@ -25,7 +25,9 @@ import com.greenart7c3.nostrsigner.AccountInfo
|
||||
import com.greenart7c3.nostrsigner.BuildConfig
|
||||
import com.greenart7c3.nostrsigner.LocalPreferences
|
||||
import com.greenart7c3.nostrsigner.NostrSigner
|
||||
import com.greenart7c3.nostrsigner.database.LogEntity
|
||||
import com.greenart7c3.nostrsigner.models.Account
|
||||
import com.greenart7c3.nostrsigner.relays.AmberListenerSingleton
|
||||
import com.vitorpamplona.ammolite.service.HttpClientManager
|
||||
import com.vitorpamplona.quartz.encoders.toHexKey
|
||||
import com.vitorpamplona.quartz.encoders.toNpub
|
||||
@@ -117,12 +119,32 @@ class RegisterAccounts(
|
||||
.build()
|
||||
|
||||
val client = HttpClientManager.getHttpClient()
|
||||
client.newCall(request).execute().use {
|
||||
if (it.isSuccessful) {
|
||||
Log.d("FirebaseMsgService", "Successfully registered with push server")
|
||||
} else {
|
||||
Log.d("FirebaseMsgService", "Failed to register with push server")
|
||||
var isSuccess = client.newCall(request).execute().use {
|
||||
it.isSuccessful
|
||||
}
|
||||
var tries = 0
|
||||
while (!isSuccess && tries < 3) {
|
||||
Log.d("FirebaseMsgService", "Failed to register with push server, retrying...")
|
||||
isSuccess = client.newCall(request).execute().use {
|
||||
it.isSuccessful
|
||||
}
|
||||
tries++
|
||||
}
|
||||
if (isSuccess) {
|
||||
Log.d("FirebaseMsgService", "Successfully registered with push server")
|
||||
} else {
|
||||
accounts.forEach {
|
||||
NostrSigner.instance.getDatabase(it.npub).applicationDao().insertLog(
|
||||
LogEntity(
|
||||
0,
|
||||
"Push server",
|
||||
"Push server",
|
||||
"Failed to register with push server",
|
||||
System.currentTimeMillis(),
|
||||
),
|
||||
)
|
||||
}
|
||||
AmberListenerSingleton.accountStateViewModel?.toast("Push server", "Failed to register with push server")
|
||||
}
|
||||
} catch (e: java.lang.Exception) {
|
||||
if (e is CancellationException) throw e
|
||||
|
||||
@@ -321,13 +321,14 @@ fun SettingsScreen(
|
||||
NotificationDataSource.stopSync()
|
||||
RelayPool.disconnect()
|
||||
} else {
|
||||
NostrSigner.instance.checkForNewRelays()
|
||||
NotificationDataSource.start()
|
||||
NostrSigner.instance.applicationContext.startService(
|
||||
Intent(
|
||||
NostrSigner.instance.applicationContext,
|
||||
ConnectivityService::class.java,
|
||||
),
|
||||
)
|
||||
NotificationDataSource.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ lifecycle_version = "2.8.2"
|
||||
material3 = "1.2.1"
|
||||
mockk = "1.13.11"
|
||||
nav_version = "2.7.7"
|
||||
quartz = "main-SNAPSHOT"
|
||||
quartz = "d6ab376f2d"
|
||||
compose_ui = "1.6.8"
|
||||
richtextUi = "077a2cde64"
|
||||
roomKtx = "2.6.1"
|
||||
|
||||
Reference in New Issue
Block a user