feat(ios): declare publish cancellation to swift, and unshadow Platform
Seven `@Throws` on the publish path now name `kotlin.coroutines.cancellation.CancellationException` alongside `NostrPublishException`. Without it a publish cancelled by the screen navigating away crosses the ObjC boundary as an unexpected throw rather than as the cancellation it is, and swift has no way to tell the two apart. Six of the seven already existed; `EventPublishTransport` had none, so the interface the group-signed path publishes through said less about itself than the implementation behind it. `Platform.ios.kt` also imported `kotlin.native.Platform`, which shadows the app's own `Platform` interface the file is there to implement. It was unused and nothing on this host compiles iosMain, so the compiler never said so. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
73b2c8ae9a
commit
fc19583225
5 files changed
+7
-7
No files matched your search
+1
@@ -28,5 +28,6 @@ interface EventPublishTransport {
|
||||
*
|
||||
* @see RelayPool.publishEvent
|
||||
*/
|
||||
@Throws(press.mantra.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class)
|
||||
suspend fun publishEvent(nostrEvent: NostrEvent, relays: Set<RelayDTO>): Flow<NostrPublishResult>
|
||||
}
|
||||
@@ -286,7 +286,7 @@ class RelayPool(
|
||||
)
|
||||
}
|
||||
|
||||
@Throws(press.mantra.compose.exceptions.NostrPublishException::class)
|
||||
@Throws(press.mantra.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class)
|
||||
suspend fun publishEvent(nostrEvent: press.mantra.compose.database.model.NostrEvent, relays: Set<press.mantra.compose.network.dto.RelayDTO> = emptySet()): Flow<NostrPublishResult> {
|
||||
val relayUrls = relays.map { NormalizedRelayUrl(it.url).displayUrl() }
|
||||
|
||||
|
||||
+2
-2
@@ -100,7 +100,7 @@ class RelaysSocketManager(
|
||||
relayPool.closePool()
|
||||
}
|
||||
|
||||
@Throws(press.mantra.compose.exceptions.NostrPublishException::class)
|
||||
@Throws(press.mantra.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class)
|
||||
suspend fun publishEvent(nostrEvent: press.mantra.compose.database.model.NostrEvent): Flow<NostrPublishResult> {
|
||||
return if (userRelays.isNotEmpty()) {
|
||||
relayPool.publishEvent(
|
||||
@@ -115,7 +115,7 @@ class RelaysSocketManager(
|
||||
}
|
||||
}
|
||||
|
||||
@Throws(press.mantra.compose.exceptions.NostrPublishException::class)
|
||||
@Throws(press.mantra.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class)
|
||||
override suspend fun publishEvent(nostrEvent: press.mantra.compose.database.model.NostrEvent, relays: Set<press.mantra.compose.network.dto.RelayDTO>): Flow<NostrPublishResult> {
|
||||
logger.d("publishEvent: $nostrEvent")
|
||||
return relayPool.publishEvent(
|
||||
|
||||
+3
-3
@@ -30,7 +30,7 @@ class NostrPublisherRepository(
|
||||
}
|
||||
}
|
||||
|
||||
@Throws(press.mantra.compose.exceptions.NostrPublishException::class)
|
||||
@Throws(press.mantra.compose.exceptions.NostrPublishException::class, kotlin.coroutines.cancellation.CancellationException::class)
|
||||
private suspend fun publishAndImportEvent(signedNostrEvent: press.mantra.compose.database.model.NostrEvent, outboxRelays: List<String> = emptyList()) {
|
||||
relaysSocketManager.publishEvent(signedNostrEvent)
|
||||
importEvent(signedNostrEvent)
|
||||
@@ -52,7 +52,7 @@ class NostrPublisherRepository(
|
||||
}
|
||||
}
|
||||
|
||||
@Throws(press.mantra.compose.exceptions.NostrPublishException::class, press.mantra.compose.exceptions.SignatureException::class)
|
||||
@Throws(press.mantra.compose.exceptions.NostrPublishException::class, press.mantra.compose.exceptions.SignatureException::class, kotlin.coroutines.cancellation.CancellationException::class)
|
||||
suspend fun signPublishImportNostrEvent(
|
||||
unsignedNostrEvent: press.mantra.compose.database.model.UnsignedNostrEvent,
|
||||
outboxRelays: List<String>,
|
||||
@@ -63,7 +63,7 @@ class NostrPublisherRepository(
|
||||
}
|
||||
|
||||
|
||||
@Throws(press.mantra.compose.exceptions.NostrPublishException::class, press.mantra.compose.exceptions.SignatureException::class)
|
||||
@Throws(press.mantra.compose.exceptions.NostrPublishException::class, press.mantra.compose.exceptions.SignatureException::class, kotlin.coroutines.cancellation.CancellationException::class)
|
||||
suspend fun publishRelayList(userId: String, relays: List<press.mantra.compose.network.dto.RelayDTO>): press.mantra.compose.database.model.NostrEvent {
|
||||
val signedNostrEvent = nostrNotary.signRelayListMetadata(userId = userId, relays = relays).unwrapOrThrow()
|
||||
relaysSocketManager.publishEvent(nostrEvent = signedNostrEvent, relays = relays.toSet())
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package press.mantra.compose
|
||||
|
||||
import platform.UIKit.UIDevice
|
||||
import kotlin.native.Platform
|
||||
|
||||
class IOSPlatform: Platform {
|
||||
override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
|
||||
|
||||
Reference in new issue
Block a user