mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-08 23:19:55 +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
|
lateinit var commonMessageInterface: CommonMessageInterface
|
||||||
|
|
||||||
|
@Suppress("Detekt.LongMethod")
|
||||||
override fun onBind(message: ChatMessage) {
|
override fun onBind(message: ChatMessage) {
|
||||||
super.onBind(message)
|
super.onBind(message)
|
||||||
sharedApplication!!.componentApplication.inject(this)
|
sharedApplication!!.componentApplication.inject(this)
|
||||||
|
@ -31,6 +31,7 @@ import retrofit2.http.Query
|
|||||||
import retrofit2.http.QueryMap
|
import retrofit2.http.QueryMap
|
||||||
import retrofit2.http.Url
|
import retrofit2.http.Url
|
||||||
|
|
||||||
|
@Suppress("TooManyFunctions")
|
||||||
interface NcApiCoroutines {
|
interface NcApiCoroutines {
|
||||||
@GET
|
@GET
|
||||||
@JvmSuppressWildcards
|
@JvmSuppressWildcards
|
||||||
|
@ -47,6 +47,7 @@ import kotlinx.coroutines.launch
|
|||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@Suppress("LargeClass", "TooManyFunctions")
|
||||||
class OfflineFirstChatRepository @Inject constructor(
|
class OfflineFirstChatRepository @Inject constructor(
|
||||||
private val chatDao: ChatMessagesDao,
|
private val chatDao: ChatMessagesDao,
|
||||||
private val chatBlocksDao: ChatBlocksDao,
|
private val chatBlocksDao: ChatBlocksDao,
|
||||||
@ -178,35 +179,39 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
Log.d(TAG, "newestMessageIdFromDb after sync: $newestMessageIdFromDb")
|
Log.d(TAG, "newestMessageIdFromDb after sync: $newestMessageIdFromDb")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newestMessageIdFromDb.toInt() != 0) {
|
handleMessagesFromDb(newestMessageIdFromDb)
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
initMessagePolling(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 {
|
private suspend fun getCappedMessagesAmountOfChatBlock(messageId: Long): Int {
|
||||||
val chatBlock = getBlockOfMessage(messageId.toInt())
|
val chatBlock = getBlockOfMessage(messageId.toInt())
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import io.reactivex.disposables.Disposable
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@Suppress("Detekt.TooManyFunctions")
|
||||||
class MessageInputViewModel @Inject constructor(
|
class MessageInputViewModel @Inject constructor(
|
||||||
private val audioRecorderManager: AudioRecorderManager,
|
private val audioRecorderManager: AudioRecorderManager,
|
||||||
private val mediaPlayerManager: MediaPlayerManager,
|
private val mediaPlayerManager: MediaPlayerManager,
|
||||||
@ -116,6 +117,7 @@ class MessageInputViewModel @Inject constructor(
|
|||||||
val callStartedFlow: LiveData<Pair<ChatMessage, Boolean>>
|
val callStartedFlow: LiveData<Pair<ChatMessage, Boolean>>
|
||||||
get() = _callStartedFlow
|
get() = _callStartedFlow
|
||||||
|
|
||||||
|
@Suppress("LongParameterList")
|
||||||
fun sendChatMessage(
|
fun sendChatMessage(
|
||||||
credentials: String,
|
credentials: String,
|
||||||
url: String,
|
url: String,
|
||||||
|
@ -61,7 +61,6 @@ import com.nextcloud.talk.translate.repositories.TranslateRepositoryImpl
|
|||||||
import com.nextcloud.talk.users.UserManager
|
import com.nextcloud.talk.users.UserManager
|
||||||
import com.nextcloud.talk.utils.DateUtils
|
import com.nextcloud.talk.utils.DateUtils
|
||||||
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
||||||
import com.nextcloud.talk.utils.preferences.AppPreferences
|
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
@ -156,7 +155,6 @@ class RepositoryModule {
|
|||||||
chatMessagesDao: ChatMessagesDao,
|
chatMessagesDao: ChatMessagesDao,
|
||||||
chatBlocksDao: ChatBlocksDao,
|
chatBlocksDao: ChatBlocksDao,
|
||||||
dataSource: ChatNetworkDataSource,
|
dataSource: ChatNetworkDataSource,
|
||||||
appPreferences: AppPreferences,
|
|
||||||
networkMonitor: NetworkMonitor,
|
networkMonitor: NetworkMonitor,
|
||||||
userProvider: CurrentUserProviderNew
|
userProvider: CurrentUserProviderNew
|
||||||
): ChatMessageRepository =
|
): ChatMessageRepository =
|
||||||
@ -164,7 +162,6 @@ class RepositoryModule {
|
|||||||
chatMessagesDao,
|
chatMessagesDao,
|
||||||
chatBlocksDao,
|
chatBlocksDao,
|
||||||
dataSource,
|
dataSource,
|
||||||
appPreferences,
|
|
||||||
networkMonitor,
|
networkMonitor,
|
||||||
userProvider
|
userProvider
|
||||||
)
|
)
|
||||||
|
@ -16,6 +16,7 @@ import com.nextcloud.talk.data.database.model.ChatMessageEntity
|
|||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
|
@Suppress("Detekt.TooManyFunctions")
|
||||||
interface ChatMessagesDao {
|
interface ChatMessagesDao {
|
||||||
@Query(
|
@Query(
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user