Commit 9115106a authored by Leonardo Aramaki's avatar Leonardo Aramaki

Handle exceptions on ChatRoomsPresenter#chatRoomsByName() method

parent 081b079c
...@@ -82,15 +82,19 @@ class ChatRoomsPresenter @Inject constructor(private val view: ChatRoomsView, ...@@ -82,15 +82,19 @@ class ChatRoomsPresenter @Inject constructor(private val view: ChatRoomsView,
fun chatRoomsByName(name: String) { fun chatRoomsByName(name: String) {
val currentServer = serverInteractor.get()!! val currentServer = serverInteractor.get()!!
launchUI(strategy) { launchUI(strategy) {
val roomList = getChatRoomsInteractor.getByName(currentServer, name) try {
if (roomList.isEmpty()) { val roomList = getChatRoomsInteractor.getByName(currentServer, name)
val (users, rooms) = client.spotlight(name) if (roomList.isEmpty()) {
val chatRoomsCombined = mutableListOf<ChatRoom>() val (users, rooms) = client.spotlight(name)
chatRoomsCombined.addAll(usersToChatRooms(users)) val chatRoomsCombined = mutableListOf<ChatRoom>()
chatRoomsCombined.addAll(roomsToChatRooms(rooms)) chatRoomsCombined.addAll(usersToChatRooms(users))
view.updateChatRooms(chatRoomsCombined) chatRoomsCombined.addAll(roomsToChatRooms(rooms))
} else { view.updateChatRooms(chatRoomsCombined)
view.updateChatRooms(roomList) } else {
view.updateChatRooms(roomList)
}
} catch (ex: RocketChatException) {
Timber.e(ex)
} }
} }
} }
......
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