Commit b2d415bb authored by Leonardo Aramaki's avatar Leonardo Aramaki

Set suspendable fun to use CommonPool

parent eefea063
......@@ -6,6 +6,8 @@ import chat.rocket.android.server.domain.MessagesRepository
import chat.rocket.core.TokenRepository
import chat.rocket.core.model.Message
import chat.rocket.core.model.Value
import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.launch
import javax.inject.Inject
class MessageViewModelMapper @Inject constructor(private val context: Context,
......@@ -13,8 +15,9 @@ class MessageViewModelMapper @Inject constructor(private val context: Context,
private val messageParser: MessageParser,
private val messagesRepository: MessagesRepository) {
suspend fun mapToViewModel(message: Message, settings: Map<String, Value<Any>>?) =
MessageViewModel(context, tokenRepository.get(), message, settings, messageParser, messagesRepository)
suspend fun mapToViewModel(message: Message, settings: Map<String, Value<Any>>?) = launch(CommonPool) {
MessageViewModel(this@MessageViewModelMapper.context, tokenRepository.get(), message, settings, messageParser, messagesRepository)
}
suspend fun mapToViewModelList(messageList: List<Message>, settings: Map<String, Value<Any>>?): List<MessageViewModel> {
return messageList.map { MessageViewModel(context, tokenRepository.get(), it, settings, messageParser, messagesRepository) }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment