From 987df2c8f61cfed15d04b7931a7ad817672df291 Mon Sep 17 00:00:00 2001 From: Kgothatso Date: Tue, 15 Sep 2026 08:58:53 +0200 Subject: [PATCH] feat(ios): declare publish cancellation and the Room constructor to swift @Throws(CancellationException) on the publish path so swift sees a cancellation as one, @ConstructedBy so Room can build the database on ios, an unused import out of Platform.ios.kt, and the development TEAM_ID for signing. --- .../kotlin/to/curare/compose/database/CurareDatabase.kt | 2 ++ .../curare/compose/network/relays/EventPublishTransport.kt | 1 + .../kotlin/to/curare/compose/network/relays/RelayPool.kt | 2 +- .../to/curare/compose/network/relays/RelaysSocketManager.kt | 4 ++-- .../curare/compose/repository/NostrPublisherRepository.kt | 6 +++--- .../src/iosMain/kotlin/to/curare/compose/Platform.ios.kt | 1 - iosApp/Configuration/Config.xcconfig | 2 +- 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/database/CurareDatabase.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/database/CurareDatabase.kt index a4c26a84..7293adc0 100644 --- a/composeApp/src/commonMain/kotlin/to/curare/compose/database/CurareDatabase.kt +++ b/composeApp/src/commonMain/kotlin/to/curare/compose/database/CurareDatabase.kt @@ -2,6 +2,7 @@ package to.curare.compose.database import androidx.room3.ColumnTypeConverters import androidx.room3.AutoMigration +import androidx.room3.ConstructedBy import androidx.room3.Database import androidx.room3.RoomDatabase import androidx.room3.immediateTransaction @@ -363,6 +364,7 @@ val GENESIS_AT = Instant.fromEpochMilliseconds(1231006505000L) AutoMigration(from = 23, to = 24), ] ) +@ConstructedBy(CurareDatabaseConstructor::class) @ColumnTypeConverters(CurareConverters::class) abstract class CurareDatabase: RoomDatabase() { /** diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/network/relays/EventPublishTransport.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/network/relays/EventPublishTransport.kt index 24328e23..a0bd913d 100644 --- a/composeApp/src/commonMain/kotlin/to/curare/compose/network/relays/EventPublishTransport.kt +++ b/composeApp/src/commonMain/kotlin/to/curare/compose/network/relays/EventPublishTransport.kt @@ -28,5 +28,6 @@ interface EventPublishTransport { * * @see RelayPool.publishEvent */ + @Throws(to.curare.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class) suspend fun publishEvent(nostrEvent: NostrEvent, relays: Set): Flow } diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/network/relays/RelayPool.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/network/relays/RelayPool.kt index b7a27ba9..812ed661 100644 --- a/composeApp/src/commonMain/kotlin/to/curare/compose/network/relays/RelayPool.kt +++ b/composeApp/src/commonMain/kotlin/to/curare/compose/network/relays/RelayPool.kt @@ -286,7 +286,7 @@ class RelayPool( ) } - @Throws(to.curare.compose.exceptions.NostrPublishException::class) + @Throws(to.curare.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class) suspend fun publishEvent(nostrEvent: to.curare.compose.database.model.NostrEvent, relays: Set = emptySet()): Flow { val relayUrls = relays.map { NormalizedRelayUrl(it.url).displayUrl() } diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/network/relays/RelaysSocketManager.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/network/relays/RelaysSocketManager.kt index 2facd97e..025e9b9a 100644 --- a/composeApp/src/commonMain/kotlin/to/curare/compose/network/relays/RelaysSocketManager.kt +++ b/composeApp/src/commonMain/kotlin/to/curare/compose/network/relays/RelaysSocketManager.kt @@ -100,7 +100,7 @@ class RelaysSocketManager( relayPool.closePool() } - @Throws(to.curare.compose.exceptions.NostrPublishException::class) + @Throws(to.curare.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class) suspend fun publishEvent(nostrEvent: to.curare.compose.database.model.NostrEvent): Flow { return if (userRelays.isNotEmpty()) { relayPool.publishEvent( @@ -115,7 +115,7 @@ class RelaysSocketManager( } } - @Throws(to.curare.compose.exceptions.NostrPublishException::class) + @Throws(to.curare.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class) override suspend fun publishEvent(nostrEvent: to.curare.compose.database.model.NostrEvent, relays: Set): Flow { logger.d("publishEvent: $nostrEvent") return relayPool.publishEvent( diff --git a/composeApp/src/commonMain/kotlin/to/curare/compose/repository/NostrPublisherRepository.kt b/composeApp/src/commonMain/kotlin/to/curare/compose/repository/NostrPublisherRepository.kt index c0818d35..d6bf1cc5 100644 --- a/composeApp/src/commonMain/kotlin/to/curare/compose/repository/NostrPublisherRepository.kt +++ b/composeApp/src/commonMain/kotlin/to/curare/compose/repository/NostrPublisherRepository.kt @@ -30,7 +30,7 @@ class NostrPublisherRepository( } } - @Throws(to.curare.compose.exceptions.NostrPublishException::class) + @Throws(to.curare.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class) private suspend fun publishAndImportEvent(signedNostrEvent: to.curare.compose.database.model.NostrEvent, outboxRelays: List = emptyList()) { relaysSocketManager.publishEvent(signedNostrEvent) importEvent(signedNostrEvent) @@ -52,7 +52,7 @@ class NostrPublisherRepository( } } - @Throws(to.curare.compose.exceptions.NostrPublishException::class, to.curare.compose.exceptions.SignatureException::class) + @Throws(to.curare.compose.exceptions.NostrPublishException::class, to.curare.compose.exceptions.SignatureException::class, kotlin.coroutines.cancellation.CancellationException::class) suspend fun signPublishImportNostrEvent( unsignedNostrEvent: to.curare.compose.database.model.UnsignedNostrEvent, outboxRelays: List, @@ -63,7 +63,7 @@ class NostrPublisherRepository( } - @Throws(to.curare.compose.exceptions.NostrPublishException::class, to.curare.compose.exceptions.SignatureException::class) + @Throws(to.curare.compose.exceptions.NostrPublishException::class, to.curare.compose.exceptions.SignatureException::class, kotlin.coroutines.cancellation.CancellationException::class) suspend fun publishRelayList(userId: String, relays: List): to.curare.compose.database.model.NostrEvent { val signedNostrEvent = nostrNotary.signRelayListMetadata(userId = userId, relays = relays).unwrapOrThrow() relaysSocketManager.publishEvent(nostrEvent = signedNostrEvent, relays = relays.toSet()) diff --git a/composeApp/src/iosMain/kotlin/to/curare/compose/Platform.ios.kt b/composeApp/src/iosMain/kotlin/to/curare/compose/Platform.ios.kt index 96998d3c..eef25180 100644 --- a/composeApp/src/iosMain/kotlin/to/curare/compose/Platform.ios.kt +++ b/composeApp/src/iosMain/kotlin/to/curare/compose/Platform.ios.kt @@ -1,7 +1,6 @@ package to.curare.compose import platform.UIKit.UIDevice -import kotlin.native.Platform class IOSPlatform: Platform { override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion diff --git a/iosApp/Configuration/Config.xcconfig b/iosApp/Configuration/Config.xcconfig index 2761b04f..3626afce 100644 --- a/iosApp/Configuration/Config.xcconfig +++ b/iosApp/Configuration/Config.xcconfig @@ -1,4 +1,4 @@ -TEAM_ID= +TEAM_ID=ZK3TQ662GB PRODUCT_NAME=Curare PRODUCT_BUNDLE_IDENTIFIER=to.curare.ios$(TEAM_ID)