Skip to content

Commit

Permalink
Fix release
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaSat committed Oct 24, 2024
1 parent 5f0dc55 commit f7f4149
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ object EncryptedStorage {
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM,
) as EncryptedSharedPreferences

_pubKey.value = sharedPreferences.getString(PrefKeys.NOSTR_PUBKEY, "").toString()
}

fun updatePubKey(newValue: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class NotificationsService : Service() {
"wss://relay.nsec.app",
"wss://relay.0xchat.com",
)
private var useDefaultRelays = false

private val timer = Timer()
private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
Expand Down Expand Up @@ -200,13 +199,7 @@ class NotificationsService : Service() {
var latestNotification = dao.getLatestNotification()
if (latestNotification == null) latestNotification = Instant.now().toEpochMilli() / 1000

var relays = dao.getRelays()
if (relays.isEmpty()) {
relays = defaultRelayUrls.map { RelayEntity(id = 0, url = it, kind = 0, createdAt = 0) }
useDefaultRelays = true
}
connectRelays(relays)

connectRelays()
Client.sendFilter(
subscriptionNotificationId,
listOf(
Expand Down Expand Up @@ -303,14 +296,13 @@ class NotificationsService : Service() {
if (lastCreatedRelayAt == null || lastCreatedRelayAt < event.createdAt) {
stopSubscription()
dao.deleteRelaysByKind(event.kind)
val relays = event.tags
event.tags
.filter { it.size > 1 && (it[0] == "relay" || it[0] == "r") }
.map {
val entity = RelayEntity(id = 0, url = it[1], kind = event.kind, createdAt = event.createdAt)
dao.insertRelay(entity)
entity
}
connectRelays(relays)
startSubscription()
}
}
Expand Down Expand Up @@ -412,25 +404,24 @@ class NotificationsService : Service() {
return hexKey
}

private fun connectRelays(relays: List<RelayEntity>) {
Log.d("Pokey", relays.toString())
if (useDefaultRelays) {
RelayPool.unloadRelays()
useDefaultRelays = false
private fun connectRelays() {
RelayPool.unloadRelays()
val dao = AppDatabase.getDatabase(this@NotificationsService, getHexKey()).applicationDao()
var relays = dao.getRelays()
if (relays.isEmpty()) {
relays = defaultRelayUrls.map { RelayEntity(id = 0, url = it, kind = 0, createdAt = 0) }
}
relays.forEach {
if (RelayPool.getRelays(it.url).isEmpty()) {
Client.sendFilterOnlyIfDisconnected()
RelayPool.addRelay(
Relay(
it.url,
read = true,
write = false,
forceProxy = false,
activeTypes = COMMON_FEED_TYPES,
),
)
}
Client.sendFilterOnlyIfDisconnected()
RelayPool.addRelay(
Relay(
it.url,
read = true,
write = false,
forceProxy = false,
activeTypes = COMMON_FEED_TYPES,
),
)
}
}
}
2 changes: 1 addition & 1 deletion zapstore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ pokey:
repository: https://github.com/koalasat/pokey
license: MIT
artifacts:
- ./app/build/outputs/apk/release/pokey-universal-v%v.apk
- ./app/build/outputs/apk/release/pokey-universal-v%v-alpha.apk

0 comments on commit f7f4149

Please sign in to comment.