mirror of
https://github.com/aljazceru/react-native-pubky.git
synced 2026-01-20 07:14:23 +01:00
feat: add list method
Adds list method. Adds put, get & list examples to README.md. Bump package version to 0.6.0.
This commit is contained in:
@@ -231,6 +231,25 @@ class PubkyModule(reactContext: ReactApplicationContext) :
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
fun list(url: String, promise: Promise) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
try {
|
||||
val result = list(url)
|
||||
val array = Arguments.createArray().apply {
|
||||
result.forEach { pushString(it) }
|
||||
}
|
||||
withContext(Dispatchers.Main) {
|
||||
promise.resolve(array)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
withContext(Dispatchers.Main) {
|
||||
promise.reject("Error", e.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val NAME = "Pubky"
|
||||
}
|
||||
|
||||
@@ -389,6 +389,8 @@ internal interface _UniFFILib : Library {
|
||||
): RustBuffer.ByValue
|
||||
fun uniffi_pubkymobile_fn_func_get(`url`: RustBuffer.ByValue,
|
||||
): Pointer
|
||||
fun uniffi_pubkymobile_fn_func_list(`url`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
|
||||
): RustBuffer.ByValue
|
||||
fun uniffi_pubkymobile_fn_func_parse_auth_url(`url`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
|
||||
): RustBuffer.ByValue
|
||||
fun uniffi_pubkymobile_fn_func_publish(`recordName`: RustBuffer.ByValue,`recordContent`: RustBuffer.ByValue,`secretKey`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
|
||||
@@ -525,6 +527,8 @@ internal interface _UniFFILib : Library {
|
||||
): Short
|
||||
fun uniffi_pubkymobile_checksum_func_get(
|
||||
): Short
|
||||
fun uniffi_pubkymobile_checksum_func_list(
|
||||
): Short
|
||||
fun uniffi_pubkymobile_checksum_func_parse_auth_url(
|
||||
): Short
|
||||
fun uniffi_pubkymobile_checksum_func_publish(
|
||||
@@ -566,6 +570,9 @@ private fun uniffiCheckApiChecksums(lib: _UniFFILib) {
|
||||
if (lib.uniffi_pubkymobile_checksum_func_get() != 5395.toShort()) {
|
||||
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
||||
}
|
||||
if (lib.uniffi_pubkymobile_checksum_func_list() != 8522.toShort()) {
|
||||
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
||||
}
|
||||
if (lib.uniffi_pubkymobile_checksum_func_parse_auth_url() != 29088.toShort()) {
|
||||
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
||||
}
|
||||
@@ -749,6 +756,14 @@ suspend fun `get`(`url`: String) : List<String> {
|
||||
)
|
||||
}
|
||||
|
||||
fun `list`(`url`: String): List<String> {
|
||||
return FfiConverterSequenceString.lift(
|
||||
rustCall() { _status ->
|
||||
_UniFFILib.INSTANCE.uniffi_pubkymobile_fn_func_list(FfiConverterString.lower(`url`),_status)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
fun `parseAuthUrl`(`url`: String): List<String> {
|
||||
return FfiConverterSequenceString.lift(
|
||||
rustCall() { _status ->
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user