Commit 11d9eea4 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

No need to specify the room type to get the mentions.

parent f780d4ee
......@@ -3,8 +3,6 @@ package chat.rocket.android.mentions.di
import androidx.lifecycle.LifecycleOwner
import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.dagger.scope.PerFragment
import chat.rocket.android.db.DatabaseManager
import chat.rocket.android.db.DatabaseManagerFactory
import chat.rocket.android.mentions.presentention.MentionsView
import chat.rocket.android.mentions.ui.MentionsFragment
import chat.rocket.android.server.domain.GetCurrentServerInteractor
......@@ -29,15 +27,6 @@ class MentionsFragmentModule {
return currentServerInteractor.get()!!
}
@Provides
@PerFragment
fun provideDatabaseManager(
factory: DatabaseManagerFactory,
@Named("currentServer") currentServer: String
): DatabaseManager {
return factory.create(currentServer)
}
@Provides
@PerFragment
fun provideJob() = Job()
......
......@@ -2,11 +2,9 @@ package chat.rocket.android.mentions.presentention
import chat.rocket.android.chatroom.uimodel.UiModelMapper
import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.db.DatabaseManager
import chat.rocket.android.server.infraestructure.RocketChatClientFactory
import chat.rocket.android.util.extensions.launchUI
import chat.rocket.common.RocketChatException
import chat.rocket.common.model.roomTypeOf
import chat.rocket.common.util.ifNull
import chat.rocket.core.internal.rest.getMentions
import timber.log.Timber
......@@ -15,7 +13,6 @@ import javax.inject.Named
class MentionsPresenter @Inject constructor(
private val view: MentionsView,
private val dbManager: DatabaseManager,
@Named("currentServer") private val currentServer: String,
private val strategy: CancelStrategy,
private val mapper: UiModelMapper,
......@@ -33,15 +30,10 @@ class MentionsPresenter @Inject constructor(
launchUI(strategy) {
try {
view.showLoading()
dbManager.getRoom(roomId)?.let {
val mentions =
client.getMentions(roomId, roomTypeOf(it.chatRoom.type), offset, 30)
val mentions = client.getMentions(roomId, offset, 30)
val mentionsList = mapper.map(mentions.result, asNotReversed = true)
view.showMentions(mentionsList)
offset += 1 * 30
}.ifNull {
Timber.e("Couldn't find a room with id: $roomId at current server.")
}
} catch (exception: RocketChatException) {
Timber.e(exception)
exception.message?.let {
......
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