Fix NewMessage with ONS

This commit is contained in:
Andrew
2024-06-18 11:28:36 +09:30
parent bf3835d6a6
commit 71e7dfb131
5 changed files with 165 additions and 197 deletions

View File

@@ -1,9 +1,6 @@
@file:JvmName("PromiseUtilities")
package org.session.libsignal.utilities
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.isActive
import nl.komponents.kovenant.Promise
import nl.komponents.kovenant.deferred
import nl.komponents.kovenant.functional.map
@@ -70,19 +67,3 @@ infix fun <V, E: Exception> Promise<V, E>.sideEffect(
callback(it)
it
}
/**
* Observe a [Promise] as a flow
*
* Warning: Promise will not be canceled on unsubscribe.
*/
fun <V, E: Exception> Promise<V, E>.asFlow() = callbackFlow {
success {
if (isActive) trySend(it)
close()
} fail {
close(it)
}
awaitClose()
}