diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/service/RegisterAccounts.kt b/app/src/main/java/com/greenart7c3/nostrsigner/service/RegisterAccounts.kt index 3e6e0458..3877e5ef 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/service/RegisterAccounts.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/service/RegisterAccounts.kt @@ -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 diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/ui/SettingsScreen.kt b/app/src/main/java/com/greenart7c3/nostrsigner/ui/SettingsScreen.kt index 53e2460e..b5eb97b5 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/ui/SettingsScreen.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/ui/SettingsScreen.kt @@ -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() } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 84829ae3..d4c3449e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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"