Skip to content

Commit

Permalink
Fix some iOS KMP converters
Browse files Browse the repository at this point in the history
  • Loading branch information
wkal-pubnub committed Feb 27, 2025
1 parent f3ecdda commit fb6adf9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ class DownloadFileImpl(
channel = channel,
fileName = fileName,
fileId = fileId,
onSuccess = callback.onSuccessHandler {
onSuccess = callback.onSuccessHandler { file ->
requireNotNull(file)
PNDownloadFileResult(
fileName = it?.name().orEmpty(),
byteStream = it?.url()?.let { url -> DownloadableImpl(inputStream = NSInputStream(uRL = url)) }
fileName = file.name(),
byteStream = file.url()?.let { url -> DownloadableImpl(inputStream = NSInputStream(uRL = url)) }
)
},
onFailure = callback.onFailureHandler()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GetFileUrlImpl(
channel = channel,
fileName = fileName,
fileId = fileId,
onSuccess = callback.onSuccessHandler { PNFileUrlResult(url = it.orEmpty()) },
onSuccess = callback.onSuccessHandler { PNFileUrlResult(url = requireNotNull(it)) },
onFailure = callback.onFailureHandler()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ class SendFileImpl(
shouldStore = shouldStore?.let { NSNumber(it) },
customMessageType = customMessageType,
onSuccess = callback.onSuccessHandler2 { uploadedFile, timetoken ->
requireNotNull(uploadedFile)
PNFileUploadResult(
status = 200,
timetoken = timetoken.toLong(),
file = PNBaseFile(
id = uploadedFile?.id().orEmpty(),
name = uploadedFile?.name().orEmpty()
id = uploadedFile.id(),
name = uploadedFile.name()
)
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ class AddMessageActionImpl(
actionValue = actionValue,
messageTimetoken = messageTimetoken.toULong(),
onSuccess = callback.onSuccessHandler { messageActionObjC ->
requireNotNull(messageActionObjC)
PNAddMessageActionResult(
action = PNMessageAction(
type = messageActionObjC?.actionType().orEmpty(),
value = messageActionObjC?.actionValue().orEmpty(),
messageTimetoken = messageActionObjC?.messageTimetoken()?.toLong() ?: 0,
type = messageActionObjC.actionType(),
value = messageActionObjC.actionValue(),
messageTimetoken = messageActionObjC.messageTimetoken().toLong(),
).apply {
uuid = messageActionObjC?.publisher()
actionTimetoken = messageActionObjC?.actionTimetoken()?.toLong()
uuid = messageActionObjC.publisher()
actionTimetoken = messageActionObjC.actionTimetoken().toLong()
}
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ internal fun createPNUUIDMetadata(from: KMPUserMetadata?): PNUUIDMetadata {
externalId = PatchValue.of(from.externalId()),
profileUrl = PatchValue.of(from.profileUrl()),
email = PatchValue.of(from.email()),
custom = PatchValue.of(from.custom()?.safeCast()),
updated = PatchValue.of(from.updated().orEmpty()),
eTag = PatchValue.of(from.eTag().orEmpty()),
custom = from.custom()?.safeCast<String, Any>()?.let { PatchValue.of(it) },
updated = from.updated()?.let { PatchValue.of(it) },
eTag = from.eTag()?.let { PatchValue.of(it) },
type = PatchValue.of(from.type()),
status = PatchValue.of(from.status())
)
Expand All @@ -64,9 +64,9 @@ internal fun createPNChannelMetadata(from: KMPChannelMetadata?): PNChannelMetada
id = from!!.id(),
name = PatchValue.of(from.name()),
description = PatchValue.of(from.descr()),
custom = PatchValue.of(from.custom()?.safeCast()),
updated = PatchValue.of(from.updated().orEmpty()),
eTag = PatchValue.of(from.eTag().orEmpty()),
custom = from.custom()?.safeCast<String, Any>()?.let { PatchValue.of(it) },
updated = from.updated()?.let { PatchValue.of(it) },
eTag = from.eTag()?.let { PatchValue.of(it) },
type = PatchValue.of(from.type()),
status = PatchValue.of(from.status())
)
Expand All @@ -90,9 +90,9 @@ internal fun createPNChannelMembership(from: KMPMembershipMetadata): PNChannelMe
id = from.channelMetadataId(),
name = PatchValue.of(from.channel()?.name()),
description = PatchValue.of(from.channel()?.descr()),
custom = PatchValue.of(from.channel()?.custom()?.safeCast()),
updated = PatchValue.of(from.channel()?.updated().orEmpty()),
eTag = PatchValue.of(from.channel()?.eTag().orEmpty()),
custom = from.channel()?.custom()?.safeCast<String, Any>()?.let { PatchValue.of(it) },
updated = from.channel()?.updated()?.let { PatchValue.of(it) },
eTag = from.channel()?.eTag()?.let { PatchValue.of(it) },
type = PatchValue.of(from.channel()?.type()),
status = PatchValue.of(from.channel()?.status())
),
Expand All @@ -109,7 +109,7 @@ internal fun createPNChannelMembership(from: KMPMembershipMetadata): PNChannelMe
internal fun createPNMember(from: KMPMembershipMetadata?): PNMember {
return PNMember(
uuid = createPNUUIDMetadata(from = from!!.user()),
custom = PatchValue.of(from.custom()?.safeCast()),
custom = from.custom()?.safeCast<String, Any>()?.let { PatchValue.of(it) },
updated = from.updated().orEmpty(),
eTag = from.eTag().orEmpty(),
status = PatchValue.of(from.status()),
Expand Down

0 comments on commit fb6adf9

Please sign in to comment.