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