resolve detekt warnings

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2025-01-06 12:41:03 +01:00
parent 560f955002
commit a58607b547
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
6 changed files with 35 additions and 28 deletions

View File

@ -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)

View File

@ -31,6 +31,7 @@ import retrofit2.http.Query
import retrofit2.http.QueryMap
import retrofit2.http.Url
@Suppress("TooManyFunctions")
interface NcApiCoroutines {
@GET
@JvmSuppressWildcards

View File

@ -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())

View File

@ -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,

View File

@ -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
)

View File

@ -16,6 +16,7 @@ import com.nextcloud.talk.data.database.model.ChatMessageEntity
import kotlinx.coroutines.flow.Flow
@Dao
@Suppress("Detekt.TooManyFunctions")
interface ChatMessagesDao {
@Query(
"""