11package chat.rocket.android.userdetails.presentation
22
3+ import chat.rocket.android.chatrooms.domain.FetchChatRoomsInteractor
34import chat.rocket.android.core.lifecycle.CancelStrategy
45import chat.rocket.android.db.DatabaseManager
56import chat.rocket.android.db.model.ChatRoomEntity
@@ -28,6 +29,7 @@ class UserDetailsPresenter @Inject constructor(
2829 private var currentServer = serverInteractor.get()!!
2930 private val manager = factory.create(currentServer)
3031 private val client = manager.client
32+ private val interactor = FetchChatRoomsInteractor (client,dbManager)
3133
3234 fun loadUserDetails (userId : String ) {
3335 launchUI(strategy) {
@@ -40,37 +42,7 @@ class UserDetailsPresenter @Inject constructor(
4042 val openedChatRooms = chatRoomByName(name = u.name)
4143 val avatarUrl = u.username?.let { currentServer.avatarUrl(avatar = it) }
4244
43- val chatRoom: ChatRoom ? = if (openedChatRooms.isEmpty()) {
44- ChatRoom (
45- id = " " ,
46- type = roomTypeOf(RoomType .DIRECT_MESSAGE ),
47- name = u.username ? : u.name.orEmpty(),
48- fullName = u.name,
49- favorite = false ,
50- open = false ,
51- alert = false ,
52- status = userStatusOf(u.status),
53- client = client,
54- broadcast = false ,
55- archived = false ,
56- default = false ,
57- description = null ,
58- groupMentions = null ,
59- userMentions = null ,
60- lastMessage = null ,
61- lastSeen = null ,
62- topic = null ,
63- announcement = null ,
64- roles = null ,
65- unread = 0 ,
66- readonly = false ,
67- muted = null ,
68- subscriptionId = " " ,
69- timestamp = null ,
70- updatedAt = null ,
71- user = null
72- )
73- } else openedChatRooms.firstOrNull()
45+ val chatRoom: ChatRoom ? = openedChatRooms.firstOrNull()
7446
7547 view.showUserDetails(
7648 avatarUrl = avatarUrl,
@@ -93,6 +65,8 @@ class UserDetailsPresenter @Inject constructor(
9365 client.createDirectMessage(username = id)
9466 }
9567
68+ interactor.refreshChatRooms()
69+
9670 val userEntity = withContext(CommonPool ) {
9771 dbManager.userDao().getUser(id = id)
9872 }
0 commit comments