mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-07 06:39:45 +00:00
resolve detekt warnings
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
560f955002
commit
a58607b547
@ -64,6 +64,7 @@ class OutcomingTextMessageViewHolder(itemView: View) :
|
||||
|
||||
lateinit var commonMessageInterface: CommonMessageInterface
|
||||
|
||||
@Suppress("Detekt.LongMethod")
|
||||
override fun onBind(message: ChatMessage) {
|
||||
super.onBind(message)
|
||||
sharedApplication!!.componentApplication.inject(this)
|
||||
|
@ -31,6 +31,7 @@ import retrofit2.http.Query
|
||||
import retrofit2.http.QueryMap
|
||||
import retrofit2.http.Url
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
interface NcApiCoroutines {
|
||||
@GET
|
||||
@JvmSuppressWildcards
|
||||
|
@ -47,6 +47,7 @@ import kotlinx.coroutines.launch
|
||||
import java.io.IOException
|
||||
import javax.inject.Inject
|
||||
|
||||
@Suppress("LargeClass", "TooManyFunctions")
|
||||
class OfflineFirstChatRepository @Inject constructor(
|
||||
private val chatDao: ChatMessagesDao,
|
||||
private val chatBlocksDao: ChatBlocksDao,
|
||||
@ -178,35 +179,39 @@ class OfflineFirstChatRepository @Inject constructor(
|
||||
Log.d(TAG, "newestMessageIdFromDb after sync: $newestMessageIdFromDb")
|
||||
}
|
||||
|
||||
if (newestMessageIdFromDb.toInt() != 0) {
|
||||
val limit = getCappedMessagesAmountOfChatBlock(newestMessageIdFromDb)
|
||||
|
||||
val list = getMessagesBeforeAndEqual(
|
||||
newestMessageIdFromDb,
|
||||
internalConversationId,
|
||||
limit
|
||||
)
|
||||
if (list.isNotEmpty()) {
|
||||
handleNewAndTempMessages(
|
||||
receivedChatMessages = list,
|
||||
lookIntoFuture = false,
|
||||
showUnreadMessagesMarker = false
|
||||
)
|
||||
}
|
||||
|
||||
sendTempChatMessages(credentials, urlForChatting)
|
||||
|
||||
// delay is a dirty workaround to make sure messages are added to adapter on initial load before dealing
|
||||
// with them (otherwise there is a race condition).
|
||||
delay(DELAY_TO_ENSURE_MESSAGES_ARE_ADDED)
|
||||
|
||||
updateUiForLastCommonRead()
|
||||
updateUiForLastReadMessage(newestMessageIdFromDb)
|
||||
}
|
||||
handleMessagesFromDb(newestMessageIdFromDb)
|
||||
|
||||
initMessagePolling(newestMessageIdFromDb)
|
||||
}
|
||||
|
||||
private suspend fun handleMessagesFromDb(newestMessageIdFromDb: Long) {
|
||||
if (newestMessageIdFromDb.toInt() != 0) {
|
||||
val limit = getCappedMessagesAmountOfChatBlock(newestMessageIdFromDb)
|
||||
|
||||
val list = getMessagesBeforeAndEqual(
|
||||
newestMessageIdFromDb,
|
||||
internalConversationId,
|
||||
limit
|
||||
)
|
||||
if (list.isNotEmpty()) {
|
||||
handleNewAndTempMessages(
|
||||
receivedChatMessages = list,
|
||||
lookIntoFuture = false,
|
||||
showUnreadMessagesMarker = false
|
||||
)
|
||||
}
|
||||
|
||||
sendTempChatMessages(credentials, urlForChatting)
|
||||
|
||||
// delay is a dirty workaround to make sure messages are added to adapter on initial load before dealing
|
||||
// with them (otherwise there is a race condition).
|
||||
delay(DELAY_TO_ENSURE_MESSAGES_ARE_ADDED)
|
||||
|
||||
updateUiForLastCommonRead()
|
||||
updateUiForLastReadMessage(newestMessageIdFromDb)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun getCappedMessagesAmountOfChatBlock(messageId: Long): Int {
|
||||
val chatBlock = getBlockOfMessage(messageId.toInt())
|
||||
|
||||
|
@ -27,6 +27,7 @@ import io.reactivex.disposables.Disposable
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
@Suppress("Detekt.TooManyFunctions")
|
||||
class MessageInputViewModel @Inject constructor(
|
||||
private val audioRecorderManager: AudioRecorderManager,
|
||||
private val mediaPlayerManager: MediaPlayerManager,
|
||||
@ -116,6 +117,7 @@ class MessageInputViewModel @Inject constructor(
|
||||
val callStartedFlow: LiveData<Pair<ChatMessage, Boolean>>
|
||||
get() = _callStartedFlow
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
fun sendChatMessage(
|
||||
credentials: String,
|
||||
url: String,
|
||||
|
@ -61,7 +61,6 @@ import com.nextcloud.talk.translate.repositories.TranslateRepositoryImpl
|
||||
import com.nextcloud.talk.users.UserManager
|
||||
import com.nextcloud.talk.utils.DateUtils
|
||||
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
||||
import com.nextcloud.talk.utils.preferences.AppPreferences
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import okhttp3.OkHttpClient
|
||||
@ -156,7 +155,6 @@ class RepositoryModule {
|
||||
chatMessagesDao: ChatMessagesDao,
|
||||
chatBlocksDao: ChatBlocksDao,
|
||||
dataSource: ChatNetworkDataSource,
|
||||
appPreferences: AppPreferences,
|
||||
networkMonitor: NetworkMonitor,
|
||||
userProvider: CurrentUserProviderNew
|
||||
): ChatMessageRepository =
|
||||
@ -164,7 +162,6 @@ class RepositoryModule {
|
||||
chatMessagesDao,
|
||||
chatBlocksDao,
|
||||
dataSource,
|
||||
appPreferences,
|
||||
networkMonitor,
|
||||
userProvider
|
||||
)
|
||||
|
@ -16,6 +16,7 @@ import com.nextcloud.talk.data.database.model.ChatMessageEntity
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
@Suppress("Detekt.TooManyFunctions")
|
||||
interface ChatMessagesDao {
|
||||
@Query(
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user