mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-06 11:28:22 +00:00
Fix connected applications
This commit is contained in:
@@ -40,6 +40,7 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
class NostrSigner : Application() {
|
||||
@@ -87,6 +88,14 @@ class NostrSigner : Application() {
|
||||
|
||||
LocalPreferences.allSavedAccounts(this).forEach {
|
||||
databases[it.npub] = AppDatabase.getDatabase(this, it.npub)
|
||||
applicationIOScope.launch {
|
||||
databases[it.npub]?.applicationDao()?.getAllNotConnected()?.forEach { app ->
|
||||
if (app.application.secret.isNotEmpty() && app.application.secret != app.application.key) {
|
||||
app.application.isConnected = true
|
||||
databases[it.npub]?.applicationDao()?.insertApplicationWithPermissions(app)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
|
||||
@@ -26,6 +26,9 @@ interface ApplicationDao {
|
||||
@Query("SELECT * FROM application where pubKey = :pubKey order by name")
|
||||
fun getAll(pubKey: String): List<ApplicationEntity>
|
||||
|
||||
@Query("SELECT * FROM application where isConnected = 0")
|
||||
fun getAllNotConnected(): List<ApplicationWithPermissions>
|
||||
|
||||
@Query(
|
||||
"""
|
||||
SELECT a.*, MAX(h.time) as latestTime
|
||||
@@ -66,7 +69,7 @@ interface ApplicationDao {
|
||||
type: String,
|
||||
): ApplicationPermissionsEntity?
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insertApplication(event: ApplicationEntity): Long?
|
||||
|
||||
@Query("UPDATE application SET name = :name WHERE `key` = :key")
|
||||
|
||||
Reference in New Issue
Block a user