Unverified Commit 27b10078 authored by Leonardo Aramaki's avatar Leonardo Aramaki Committed by GitHub

Merge pull request #1930 from dabbler011/nullfix

[FIX] roomid or username required bug
parents a2535dd8 dd3a2f48
package chat.rocket.android.userdetails.presentation
import chat.rocket.android.chatrooms.domain.FetchChatRoomsInteractor
import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.db.DatabaseManager
import chat.rocket.android.db.model.ChatRoomEntity
......@@ -28,6 +29,7 @@ class UserDetailsPresenter @Inject constructor(
private var currentServer = serverInteractor.get()!!
private val manager = factory.create(currentServer)
private val client = manager.client
private val interactor = FetchChatRoomsInteractor(client,dbManager)
fun loadUserDetails(userId: String) {
launchUI(strategy) {
......@@ -40,37 +42,7 @@ class UserDetailsPresenter @Inject constructor(
val openedChatRooms = chatRoomByName(name = u.name)
val avatarUrl = u.username?.let { currentServer.avatarUrl(avatar = it) }
val chatRoom: ChatRoom? = if (openedChatRooms.isEmpty()) {
ChatRoom(
id = "",
type = roomTypeOf(RoomType.DIRECT_MESSAGE),
name = u.username ?: u.name.orEmpty(),
fullName = u.name,
favorite = false,
open = false,
alert = false,
status = userStatusOf(u.status),
client = client,
broadcast = false,
archived = false,
default = false,
description = null,
groupMentions = null,
userMentions = null,
lastMessage = null,
lastSeen = null,
topic = null,
announcement = null,
roles = null,
unread = 0,
readonly = false,
muted = null,
subscriptionId = "",
timestamp = null,
updatedAt = null,
user = null
)
} else openedChatRooms.firstOrNull()
val chatRoom: ChatRoom? = openedChatRooms.firstOrNull()
view.showUserDetails(
avatarUrl = avatarUrl,
......@@ -93,6 +65,8 @@ class UserDetailsPresenter @Inject constructor(
client.createDirectMessage(username = id)
}
interactor.refreshChatRooms()
val userEntity = withContext(CommonPool) {
dbManager.userDao().getUser(id = id)
}
......
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