From 38614be92de76e2b1cf735bb49a73249e211100f Mon Sep 17 00:00:00 2001 From: Mikhail Guliaev <48011967+mgulyaev10@users.noreply.github.com> Date: Wed, 4 Oct 2023 13:39:39 +0200 Subject: [PATCH] feat: add logs (#94) --- .../conversation/list/ConversationsListViewModel.kt | 3 +++ .../storage/repository/ConversationsRepository.kt | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/tech/relaycorp/letro/conversation/list/ConversationsListViewModel.kt b/app/src/main/java/tech/relaycorp/letro/conversation/list/ConversationsListViewModel.kt index c585f6b9..03051c57 100644 --- a/app/src/main/java/tech/relaycorp/letro/conversation/list/ConversationsListViewModel.kt +++ b/app/src/main/java/tech/relaycorp/letro/conversation/list/ConversationsListViewModel.kt @@ -1,5 +1,6 @@ package tech.relaycorp.letro.conversation.list +import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel @@ -17,6 +18,7 @@ import tech.relaycorp.letro.conversation.list.onboarding.ConversationsOnboarding import tech.relaycorp.letro.conversation.list.section.ConversationSectionInfo import tech.relaycorp.letro.conversation.list.ui.ConversationsListContent import tech.relaycorp.letro.conversation.storage.repository.ConversationsRepository +import tech.relaycorp.letro.conversation.storage.repository.ConversationsRepositoryImpl import tech.relaycorp.letro.main.home.badge.UnreadBadgesManager import javax.inject.Inject @@ -49,6 +51,7 @@ class ConversationsListViewModel @Inject constructor( conversations.filter { it.isArchived } } } + Log.d(ConversationsRepositoryImpl.TAG, "Displaying new messages for state ${currentTab.currentSection} with size = ${conversations.size}") if (conversations.isNotEmpty()) { ConversationsListContent.Conversations(conversations) } else { diff --git a/app/src/main/java/tech/relaycorp/letro/conversation/storage/repository/ConversationsRepository.kt b/app/src/main/java/tech/relaycorp/letro/conversation/storage/repository/ConversationsRepository.kt index 00d96e7d..e70b726b 100644 --- a/app/src/main/java/tech/relaycorp/letro/conversation/storage/repository/ConversationsRepository.kt +++ b/app/src/main/java/tech/relaycorp/letro/conversation/storage/repository/ConversationsRepository.kt @@ -1,5 +1,6 @@ package tech.relaycorp.letro.conversation.storage.repository +import android.util.Log import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -91,6 +92,7 @@ class ConversationsRepositoryImpl @Inject constructor( startCollectContacts(currentAccount) startCollectConversations(currentAccount) } else { + Log.d(TAG, "Current account is null. Emitting empty conversations.") _extendedConversations.emit(emptyList()) contacts.emit(emptyList()) } @@ -255,6 +257,7 @@ class ConversationsRepositoryImpl @Inject constructor( val messagesOfCurrentAccount = messages.filter { it.ownerVeraId == account.accountId } val messageIdsOfCurrentAccount = messagesOfCurrentAccount.map { it.id }.toSet() + Log.d(TAG, "Emitting conversations before formatting with size: ${conversations.size}") _extendedConversations.emit( conversationsConverter.convert( conversations = conversations.filter { it.ownerVeraId == account.accountId }, @@ -262,9 +265,13 @@ class ConversationsRepositoryImpl @Inject constructor( contacts = contacts.filter { it.ownerVeraId == account.accountId }, attachments = attachments.filter { messageIdsOfCurrentAccount.contains(it.messageId) }, ownerVeraId = account.accountId, - ), + ).also { Log.d(TAG, "Emitting Extended conversations after formatting with size: ${it.size}") }, ) }.collect() } } + + companion object { + const val TAG = "ConversationsRepository" + } }