Skip to content

Commit

Permalink
feat: add logs (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
migulyaev authored Oct 4, 2023
1 parent 44843ab commit 38614be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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())
}
Expand Down Expand Up @@ -255,16 +257,21 @@ 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 },
messages = messagesOfCurrentAccount,
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"
}
}

0 comments on commit 38614be

Please sign in to comment.