mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-31 11:50:09 +08:00
Fix Flow<Message>.toMessageChain
This commit is contained in:
parent
8840ba9e6f
commit
415f133cbc
@ -464,7 +464,7 @@ public fun Stream<Message>.toMessageChain(): MessageChain = this.asSequence().to
|
|||||||
*/
|
*/
|
||||||
@JvmName("newChain")
|
@JvmName("newChain")
|
||||||
public suspend fun Flow<Message>.toMessageChain(): MessageChain =
|
public suspend fun Flow<Message>.toMessageChain(): MessageChain =
|
||||||
buildMessageChain { collect(::add) }
|
buildMessageChain { collect { add(it) } }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扁平化 [this] 并创建一个 [MessageChain].
|
* 扁平化 [this] 并创建一个 [MessageChain].
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2021 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||||
@ -8,7 +8,10 @@
|
|||||||
*/
|
*/
|
||||||
package net.mamoe.mirai.message.data
|
package net.mamoe.mirai.message.data
|
||||||
|
|
||||||
|
import kotlinx.coroutines.flow.flowOf
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
|
import kotlin.test.assertEquals
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
|
|
||||||
@ -21,4 +24,9 @@ internal class MessageUtilsTest {
|
|||||||
assertTrue { (PlainText("") + PlainText("")).isContentEmpty() }
|
assertTrue { (PlainText("") + PlainText("")).isContentEmpty() }
|
||||||
assertTrue { buildMessageChain { append(PlainText("")); append(PlainText("")) }.isContentEmpty() }
|
assertTrue { buildMessageChain { append(PlainText("")); append(PlainText("")) }.isContentEmpty() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `flow toMessageChain`(): Unit = runBlocking {
|
||||||
|
assertEquals(messageChainOf(PlainText("1")), flowOf(PlainText("1")).toMessageChain())
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user