Rename `MailboxUiItem` -> `MailboxItemUiModel`
CLIENT-4412
This commit is contained in:
parent
be81f861c1
commit
b1a653f610
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
* Copyright (c) 2022 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
|
@ -43,7 +43,7 @@ import ch.protonmail.android.events.NoResultsEvent
|
|||
import ch.protonmail.android.events.SearchResultEvent
|
||||
import ch.protonmail.android.jobs.SearchMessagesJob
|
||||
import ch.protonmail.android.mailbox.presentation.MailboxViewModel
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxUiItem
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxItemUiModel
|
||||
import ch.protonmail.android.utils.AppUtil
|
||||
import com.squareup.otto.Subscribe
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
@ -102,7 +102,7 @@ internal class SearchActivity : BaseActivity() {
|
|||
}
|
||||
}
|
||||
})
|
||||
adapter.setItemClick { mailboxUiItem: MailboxUiItem ->
|
||||
adapter.setItemClick { mailboxUiItem: MailboxItemUiModel ->
|
||||
if (isDraft(mailboxUiItem)) {
|
||||
val intent =
|
||||
AppUtil.decorInAppIntent(Intent(this@SearchActivity, ComposeMessageActivity::class.java))
|
||||
|
@ -128,7 +128,7 @@ internal class SearchActivity : BaseActivity() {
|
|||
|
||||
}
|
||||
|
||||
private fun showSearchResults(items: List<MailboxUiItem>) {
|
||||
private fun showSearchResults(items: List<MailboxItemUiModel>) {
|
||||
adapter.submitList(items)
|
||||
progressBar.visibility = View.GONE
|
||||
adapter.setNewLocation(MessageLocationType.SEARCH)
|
||||
|
@ -195,7 +195,7 @@ internal class SearchActivity : BaseActivity() {
|
|||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun isDraft(item: MailboxUiItem): Boolean {
|
||||
private fun isDraft(item: MailboxItemUiModel): Boolean {
|
||||
val messageLocation = item.messageData?.location?.let { fromInt(it) }
|
||||
return messageLocation === MessageLocationType.ALL_DRAFT ||
|
||||
messageLocation === MessageLocationType.DRAFT
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
* Copyright (c) 2022 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
|
@ -24,17 +24,16 @@ import androidx.recyclerview.widget.ListAdapter
|
|||
import ch.protonmail.android.core.Constants
|
||||
import ch.protonmail.android.data.local.model.PendingSend
|
||||
import ch.protonmail.android.data.local.model.PendingUpload
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxUiItem
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxItemUiModel
|
||||
import ch.protonmail.android.utils.ui.selection.SelectionModeEnum
|
||||
import ch.protonmail.android.views.messagesList.MailboxItemFooterView
|
||||
import ch.protonmail.android.views.messagesList.MailboxItemView
|
||||
import kotlinx.android.synthetic.main.layout_sender_initial.view.*
|
||||
import kotlinx.android.synthetic.main.list_item_mailbox.view.*
|
||||
|
||||
class MailboxRecyclerViewAdapter(
|
||||
private val context: Context,
|
||||
private val onSelectionModeChange: ((SelectionModeEnum) -> Unit)?
|
||||
) : ListAdapter<MailboxUiItem, MailboxItemViewHolder>(MailboxUiItem.DiffCallback()) {
|
||||
) : ListAdapter<MailboxItemUiModel, MailboxItemViewHolder>(MailboxItemUiModel.DiffCallback()) {
|
||||
|
||||
private var mailboxLocation = Constants.MessageLocationType.INVALID
|
||||
|
||||
|
@ -43,15 +42,15 @@ class MailboxRecyclerViewAdapter(
|
|||
private var pendingUploadList: List<PendingUpload>? = null
|
||||
private var pendingSendList: List<PendingSend>? = null
|
||||
|
||||
private var onItemClick: ((MailboxUiItem) -> Unit)? = null
|
||||
private var onItemClick: ((MailboxItemUiModel) -> Unit)? = null
|
||||
private var onItemSelectionChangedListener: (() -> Unit)? = null
|
||||
|
||||
val checkedMailboxItems get() =
|
||||
selectedMailboxItemsIds.mapNotNull { currentList.find { message -> message.itemId == it } }
|
||||
|
||||
public fun getMailboxItem(position: Int): MailboxUiItem = getItem(position)
|
||||
public fun getMailboxItem(position: Int): MailboxItemUiModel = getItem(position)
|
||||
|
||||
fun setItemClick(onItemClick: ((MailboxUiItem) -> Unit)?) {
|
||||
fun setItemClick(onItemClick: ((MailboxItemUiModel) -> Unit)?) {
|
||||
this.onItemClick = onItemClick
|
||||
}
|
||||
|
||||
|
@ -178,7 +177,7 @@ class MailboxRecyclerViewAdapter(
|
|||
}
|
||||
|
||||
/**
|
||||
* @return `true` if any items withing the given positions' range has an [MailboxUiItem.itemId] that matches one
|
||||
* @return `true` if any items withing the given positions' range has an [MailboxItemUiModel.itemId] that matches one
|
||||
* from [mailboxItemsIds]
|
||||
*/
|
||||
fun isAnyMailboxItemWithinPositions(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
* Copyright (c) 2022 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
|
@ -19,7 +19,7 @@
|
|||
package ch.protonmail.android.api.models;
|
||||
|
||||
import ch.protonmail.android.data.local.model.Message;
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxUiItem;
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxItemUiModel;
|
||||
|
||||
public class SimpleMessage {
|
||||
|
||||
|
@ -27,10 +27,10 @@ public class SimpleMessage {
|
|||
private final boolean isRead;
|
||||
private final boolean isStarred;
|
||||
|
||||
public SimpleMessage(MailboxUiItem mailboxUiItem) {
|
||||
messageID = mailboxUiItem.getItemId();
|
||||
isRead = mailboxUiItem.isRead();
|
||||
isStarred = mailboxUiItem.isStarred();
|
||||
public SimpleMessage(MailboxItemUiModel mailboxItemUiModel) {
|
||||
messageID = mailboxItemUiModel.getItemId();
|
||||
isRead = mailboxItemUiModel.isRead();
|
||||
isStarred = mailboxItemUiModel.isStarred();
|
||||
}
|
||||
|
||||
public SimpleMessage(Message message) {
|
||||
|
|
|
@ -47,7 +47,7 @@ import ch.protonmail.android.mailbox.domain.usecase.ObserveConversationsByLocati
|
|||
import ch.protonmail.android.mailbox.domain.usecase.ObserveMessagesByLocation
|
||||
import ch.protonmail.android.mailbox.presentation.ConversationModeEnabled
|
||||
import ch.protonmail.android.mailbox.presentation.MailboxViewModel
|
||||
import ch.protonmail.android.mailbox.presentation.mapper.MailboxUiItemMapper
|
||||
import ch.protonmail.android.mailbox.presentation.mapper.MailboxItemUiModelMapper
|
||||
import ch.protonmail.android.settings.domain.GetMailSettings
|
||||
import ch.protonmail.android.settings.pin.viewmodel.PinFragmentViewModelFactory
|
||||
import ch.protonmail.android.usecase.VerifyConnection
|
||||
|
@ -122,7 +122,7 @@ internal class ViewModelModule {
|
|||
drawerFoldersAndLabelsSectionUiModelMapper: DrawerFoldersAndLabelsSectionUiModelMapper,
|
||||
getMailSettings: GetMailSettings,
|
||||
messageRecipientToCorrespondentMapper: MessageRecipientToCorrespondentMapper,
|
||||
mailboxUiItemMapper: MailboxUiItemMapper,
|
||||
mailboxItemUiModelMapper: MailboxItemUiModelMapper,
|
||||
fetchEventsAndReschedule: FetchEventsAndReschedule
|
||||
) = MailboxViewModel(
|
||||
messageDetailsRepositoryFactory = messageDetailsRepositoryFactory,
|
||||
|
@ -150,7 +150,7 @@ internal class ViewModelModule {
|
|||
drawerFoldersAndLabelsSectionUiModelMapper = drawerFoldersAndLabelsSectionUiModelMapper,
|
||||
getMailSettings = getMailSettings,
|
||||
messageRecipientToCorrespondentMapper = messageRecipientToCorrespondentMapper,
|
||||
mailboxUiItemMapper = mailboxUiItemMapper,
|
||||
mailboxUiItemMapper = mailboxItemUiModelMapper,
|
||||
fetchEventsAndReschedule = fetchEventsAndReschedule
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
* Copyright (c) 2022 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
|
@ -100,7 +100,7 @@ import ch.protonmail.android.labels.domain.model.LabelId
|
|||
import ch.protonmail.android.labels.domain.model.LabelType
|
||||
import ch.protonmail.android.labels.presentation.ui.LabelsActionSheet
|
||||
import ch.protonmail.android.mailbox.presentation.MailboxViewModel.MaxLabelsReached
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxUiItem
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxItemUiModel
|
||||
import ch.protonmail.android.navigation.presentation.EXTRA_FIRST_LOGIN
|
||||
import ch.protonmail.android.navigation.presentation.NavigationActivity
|
||||
import ch.protonmail.android.prefs.SecureSharedPreferences
|
||||
|
@ -302,7 +302,7 @@ internal class MailboxActivity :
|
|||
userManager.firstMailboxLoadDone()
|
||||
}
|
||||
|
||||
mailboxAdapter.setItemClick { mailboxUiItem: MailboxUiItem ->
|
||||
mailboxAdapter.setItemClick { mailboxUiItem: MailboxItemUiModel ->
|
||||
OnMessageClickTask(
|
||||
WeakReference(this@MailboxActivity),
|
||||
messageDetailsRepositoryFactory,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
* Copyright (c) 2022 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
|
@ -19,7 +19,7 @@
|
|||
|
||||
package ch.protonmail.android.mailbox.presentation
|
||||
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxUiItem
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxItemUiModel
|
||||
import me.proton.core.util.kotlin.EMPTY_STRING
|
||||
|
||||
sealed class MailboxState {
|
||||
|
@ -39,7 +39,7 @@ sealed class MailboxState {
|
|||
* @property isFreshData if `true` we already refreshed from remote, otherwise we're relying on cache
|
||||
*/
|
||||
data class Data(
|
||||
val items: List<MailboxUiItem>,
|
||||
val items: List<MailboxItemUiModel>,
|
||||
val isFreshData: Boolean,
|
||||
val shouldResetPosition: Boolean = false
|
||||
) : MailboxState()
|
||||
|
|
|
@ -56,8 +56,8 @@ import ch.protonmail.android.mailbox.domain.usecase.ObserveAllUnreadCounters
|
|||
import ch.protonmail.android.mailbox.domain.usecase.ObserveConversationModeEnabled
|
||||
import ch.protonmail.android.mailbox.domain.usecase.ObserveConversationsByLocation
|
||||
import ch.protonmail.android.mailbox.domain.usecase.ObserveMessagesByLocation
|
||||
import ch.protonmail.android.mailbox.presentation.mapper.MailboxUiItemMapper
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxUiItem
|
||||
import ch.protonmail.android.mailbox.presentation.mapper.MailboxItemUiModelMapper
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxItemUiModel
|
||||
import ch.protonmail.android.settings.domain.GetMailSettings
|
||||
import ch.protonmail.android.usecase.VerifyConnection
|
||||
import ch.protonmail.android.usecase.delete.DeleteMessage
|
||||
|
@ -127,7 +127,7 @@ internal class MailboxViewModel @Inject constructor(
|
|||
private val drawerFoldersAndLabelsSectionUiModelMapper: DrawerFoldersAndLabelsSectionUiModelMapper,
|
||||
private val getMailSettings: GetMailSettings,
|
||||
private val messageRecipientToCorrespondentMapper: MessageRecipientToCorrespondentMapper,
|
||||
private val mailboxUiItemMapper: MailboxUiItemMapper,
|
||||
private val mailboxItemUiModelMapper: MailboxItemUiModelMapper,
|
||||
private val fetchEventsAndReschedule: FetchEventsAndReschedule
|
||||
) : ConnectivityBaseViewModel(verifyConnection, networkConfigurator) {
|
||||
|
||||
|
@ -429,14 +429,14 @@ internal class MailboxViewModel @Inject constructor(
|
|||
conversations: List<Conversation>,
|
||||
locationId: String,
|
||||
labels: List<Label>
|
||||
): List<MailboxUiItem> =
|
||||
mailboxUiItemMapper.toUiItems(
|
||||
): List<MailboxItemUiModel> =
|
||||
mailboxItemUiModelMapper.toUiModels(
|
||||
conversations = conversations,
|
||||
currentLabelId = LabelId(locationId),
|
||||
allLabels = labels
|
||||
)
|
||||
|
||||
private suspend fun messagesToMailboxItems(messages: List<Message>, labelsList: List<Label>?): List<MailboxUiItem> {
|
||||
private suspend fun messagesToMailboxItems(messages: List<Message>, labelsList: List<Label>?): List<MailboxItemUiModel> {
|
||||
Timber.v("messagesToMailboxItems size: ${messages.size}")
|
||||
|
||||
val labelIds = messages.flatMap { message -> message.allLabelIDs }.distinct().map { LabelId(it) }
|
||||
|
@ -445,7 +445,7 @@ internal class MailboxViewModel @Inject constructor(
|
|||
.chunked(Constants.MAX_SQL_ARGUMENTS)
|
||||
.flatMap { idsChunk -> labelRepository.findLabels(idsChunk) }
|
||||
|
||||
return mailboxUiItemMapper.toUiItems(messages, allLabels)
|
||||
return mailboxItemUiModelMapper.toUiModels(messages, allLabels)
|
||||
}
|
||||
|
||||
fun deleteAction(
|
||||
|
@ -605,7 +605,7 @@ internal class MailboxViewModel @Inject constructor(
|
|||
|
||||
fun handleConversationSwipe(
|
||||
swipeAction: SwipeAction,
|
||||
mailboxUiItem: MailboxUiItem,
|
||||
mailboxUiItem: MailboxItemUiModel,
|
||||
mailboxLocation: Constants.MessageLocationType,
|
||||
mailboxLocationId: String
|
||||
) {
|
||||
|
|
|
@ -31,7 +31,7 @@ import ch.protonmail.android.labels.presentation.mapper.LabelChipUiModelMapper
|
|||
import ch.protonmail.android.mailbox.data.mapper.MessageRecipientToCorrespondentMapper
|
||||
import ch.protonmail.android.mailbox.domain.model.Conversation
|
||||
import ch.protonmail.android.mailbox.domain.model.Correspondent
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxUiItem
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxItemUiModel
|
||||
import ch.protonmail.android.mailbox.presentation.model.MessageData
|
||||
import kotlinx.coroutines.flow.first
|
||||
import me.proton.core.domain.arch.Mapper
|
||||
|
@ -39,13 +39,13 @@ import me.proton.core.util.kotlin.EMPTY_STRING
|
|||
import me.proton.core.util.kotlin.takeIfNotBlank
|
||||
import javax.inject.Inject
|
||||
|
||||
class MailboxUiItemMapper @Inject constructor(
|
||||
class MailboxItemUiModelMapper @Inject constructor(
|
||||
private val contactsRepository: ContactsRepository,
|
||||
private val messageRecipientToCorrespondentMapper: MessageRecipientToCorrespondentMapper,
|
||||
private val labelChipUiModelMapper: LabelChipUiModelMapper
|
||||
) : Mapper<Either<Message, Conversation>, MailboxUiItem> {
|
||||
) : Mapper<Either<Message, Conversation>, MailboxItemUiModel> {
|
||||
|
||||
suspend fun toUiItem(message: Message, allLabels: Collection<Label>): MailboxUiItem = MailboxUiItem(
|
||||
suspend fun toUiModel(message: Message, allLabels: Collection<Label>): MailboxItemUiModel = MailboxItemUiModel(
|
||||
itemId = checkNotNull(message.messageId) { "Message id is null" },
|
||||
senderName = toDisplayNameFromContacts(message.sender, message.senderDisplayName),
|
||||
subject = checkNotNull(message.subject) { "Message subject is null" },
|
||||
|
@ -61,14 +61,14 @@ class MailboxUiItemMapper @Inject constructor(
|
|||
isDraft = message.isDraft()
|
||||
)
|
||||
|
||||
suspend fun toUiItems(messages: Collection<Message>, allLabels: Collection<Label>): List<MailboxUiItem> =
|
||||
messages.map { toUiItem(it, allLabels) }
|
||||
suspend fun toUiModels(messages: Collection<Message>, allLabels: Collection<Label>): List<MailboxItemUiModel> =
|
||||
messages.map { toUiModel(it, allLabels) }
|
||||
|
||||
suspend fun toUiItem(
|
||||
suspend fun toUiModel(
|
||||
conversation: Conversation,
|
||||
currentLabelId: LabelId,
|
||||
allLabels: Collection<Label>
|
||||
) = MailboxUiItem(
|
||||
) = MailboxItemUiModel(
|
||||
itemId = conversation.id,
|
||||
senderName = toDisplayNamesFromContacts(conversation.senders).joinToString(),
|
||||
subject = conversation.subject,
|
||||
|
@ -84,11 +84,11 @@ class MailboxUiItemMapper @Inject constructor(
|
|||
isDraft = conversation.containsSingleDraftMessage()
|
||||
)
|
||||
|
||||
suspend fun toUiItems(
|
||||
suspend fun toUiModels(
|
||||
conversations: Collection<Conversation>,
|
||||
currentLabelId: LabelId,
|
||||
allLabels: Collection<Label>
|
||||
): List<MailboxUiItem> = conversations.map { toUiItem(it, currentLabelId, allLabels) }
|
||||
): List<MailboxItemUiModel> = conversations.map { toUiModel(it, currentLabelId, allLabels) }
|
||||
|
||||
private suspend fun toDisplayNameFromContacts(sender: MessageSender?, senderDisplayName: String?): String {
|
||||
checkNotNull(sender) { "Message has null sender" }
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Proton Technologies AG
|
||||
* Copyright (c) 2022 Proton Technologies AG
|
||||
*
|
||||
* This file is part of ProtonMail.
|
||||
*
|
||||
|
@ -22,7 +22,7 @@ package ch.protonmail.android.mailbox.presentation.model
|
|||
import androidx.recyclerview.widget.DiffUtil
|
||||
import ch.protonmail.android.ui.model.LabelChipUiModel
|
||||
|
||||
data class MailboxUiItem(
|
||||
data class MailboxItemUiModel(
|
||||
val itemId: String,
|
||||
val senderName: String,
|
||||
val subject: String,
|
||||
|
@ -38,12 +38,12 @@ data class MailboxUiItem(
|
|||
val isDraft: Boolean
|
||||
) {
|
||||
|
||||
class DiffCallback : DiffUtil.ItemCallback<MailboxUiItem>() {
|
||||
class DiffCallback : DiffUtil.ItemCallback<MailboxItemUiModel>() {
|
||||
|
||||
override fun areItemsTheSame(oldItem: MailboxUiItem, newItem: MailboxUiItem) =
|
||||
override fun areItemsTheSame(oldItem: MailboxItemUiModel, newItem: MailboxItemUiModel) =
|
||||
oldItem.itemId == newItem.itemId
|
||||
|
||||
override fun areContentsTheSame(oldItem: MailboxUiItem, newItem: MailboxUiItem) =
|
||||
override fun areContentsTheSame(oldItem: MailboxItemUiModel, newItem: MailboxItemUiModel) =
|
||||
oldItem == newItem
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import ch.protonmail.android.R
|
||||
import ch.protonmail.android.core.Constants.MessageLocationType
|
||||
import ch.protonmail.android.databinding.ListItemMailboxBinding
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxUiItem
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxItemUiModel
|
||||
import ch.protonmail.android.ui.view.SingleLineLabelChipGroupView
|
||||
import ch.protonmail.android.utils.DateUtil
|
||||
import kotlinx.android.synthetic.main.list_item_mailbox.view.*
|
||||
|
@ -90,14 +90,14 @@ class MailboxItemView @JvmOverloads constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun getCorrespondentsText(mailboxUiItem: MailboxUiItem, location: MessageLocationType) =
|
||||
private fun getCorrespondentsText(mailboxUiItem: MailboxItemUiModel, location: MessageLocationType) =
|
||||
if (isDraftOrSentItem(mailboxUiItem, location)) {
|
||||
mailboxUiItem.recipients
|
||||
} else {
|
||||
mailboxUiItem.senderName
|
||||
}
|
||||
|
||||
private fun isDraftOrSentItem(mailboxUiItem: MailboxUiItem, location: MessageLocationType): Boolean {
|
||||
private fun isDraftOrSentItem(mailboxUiItem: MailboxItemUiModel, location: MessageLocationType): Boolean {
|
||||
val messageLocation = mailboxUiItem.messageData?.location
|
||||
?: MessageLocationType.INVALID.messageLocationTypeValue
|
||||
return any(location, MessageLocationType.fromInt(messageLocation)) {
|
||||
|
@ -118,7 +118,7 @@ class MailboxItemView @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
fun bind(
|
||||
mailboxUiItem: MailboxUiItem,
|
||||
mailboxUiItem: MailboxItemUiModel,
|
||||
isMultiSelectionMode: Boolean,
|
||||
mailboxLocation: MessageLocationType,
|
||||
isBeingSent: Boolean,
|
||||
|
|
|
@ -61,8 +61,8 @@ import ch.protonmail.android.mailbox.domain.usecase.ObserveMessagesByLocation
|
|||
import ch.protonmail.android.mailbox.presentation.ConversationModeEnabled
|
||||
import ch.protonmail.android.mailbox.presentation.MailboxState
|
||||
import ch.protonmail.android.mailbox.presentation.MailboxViewModel
|
||||
import ch.protonmail.android.mailbox.presentation.mapper.MailboxUiItemMapper
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxUiItem
|
||||
import ch.protonmail.android.mailbox.presentation.mapper.MailboxItemUiModelMapper
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxItemUiModel
|
||||
import ch.protonmail.android.mailbox.presentation.model.MessageData
|
||||
import ch.protonmail.android.settings.domain.GetMailSettings
|
||||
import ch.protonmail.android.ui.model.LabelChipUiModel
|
||||
|
@ -154,9 +154,9 @@ class MailboxViewModelTest : ArchTest, CoroutinesTest {
|
|||
|
||||
private val messageRecipientToCorrespondentMapper = MessageRecipientToCorrespondentMapper()
|
||||
|
||||
private val mailboxUiItemMapper: MailboxUiItemMapper = mockk {
|
||||
coEvery { toUiItems(any(), any()) } returns emptyList()
|
||||
coEvery { toUiItems(any(), any(), any()) } returns emptyList()
|
||||
private val mailboxItemUiModelMapper: MailboxItemUiModelMapper = mockk {
|
||||
coEvery { toUiModels(any(), any()) } returns emptyList()
|
||||
coEvery { toUiModels(any(), any(), any()) } returns emptyList()
|
||||
}
|
||||
|
||||
private val fetchEventsAndReschedule: FetchEventsAndReschedule = mockk {
|
||||
|
@ -243,7 +243,7 @@ class MailboxViewModelTest : ArchTest, CoroutinesTest {
|
|||
drawerFoldersAndLabelsSectionUiModelMapper = mockk(),
|
||||
getMailSettings = getMailSettings,
|
||||
messageRecipientToCorrespondentMapper = messageRecipientToCorrespondentMapper,
|
||||
mailboxUiItemMapper = mailboxUiItemMapper,
|
||||
mailboxUiItemMapper = mailboxItemUiModelMapper,
|
||||
fetchEventsAndReschedule = fetchEventsAndReschedule
|
||||
)
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ class MailboxViewModelTest : ArchTest, CoroutinesTest {
|
|||
fun verifyBasicInitFlowWithEmptyMessages() = runBlockingTest {
|
||||
// Given
|
||||
val messages = emptyList<Message>()
|
||||
val expected = emptyList<MailboxUiItem>().toMailboxState()
|
||||
val expected = emptyList<MailboxItemUiModel>().toMailboxState()
|
||||
|
||||
// When
|
||||
viewModel.mailboxState.test {
|
||||
|
@ -292,7 +292,7 @@ class MailboxViewModelTest : ArchTest, CoroutinesTest {
|
|||
val message = Message()
|
||||
val messages = listOf(message)
|
||||
val mailboxUiItems = listOf(buildMailboxUiItem())
|
||||
coEvery { mailboxUiItemMapper.toUiItems(listOf(message), any()) } returns mailboxUiItems
|
||||
coEvery { mailboxItemUiModelMapper.toUiModels(listOf(message), any()) } returns mailboxUiItems
|
||||
val expectedState = mailboxUiItems.toMailboxState()
|
||||
|
||||
// When
|
||||
|
@ -312,7 +312,7 @@ class MailboxViewModelTest : ArchTest, CoroutinesTest {
|
|||
val conversations = listOf(buildConversation())
|
||||
val successResult = GetConversationsResult.Success(conversations)
|
||||
val mailboxUiItems = listOf(buildMailboxUiItem())
|
||||
coEvery { mailboxUiItemMapper.toUiItems(conversations, location.asLabelId(), any()) } returns mailboxUiItems
|
||||
coEvery { mailboxItemUiModelMapper.toUiModels(conversations, location.asLabelId(), any()) } returns mailboxUiItems
|
||||
|
||||
val expected = mailboxUiItems.toMailboxState()
|
||||
|
||||
|
@ -537,9 +537,9 @@ class MailboxViewModelTest : ArchTest, CoroutinesTest {
|
|||
coVerify(exactly = 2) { fetchEventsAndReschedule() }
|
||||
}
|
||||
|
||||
private fun MailboxUiItem.toMailboxState() = listOf(this).toMailboxState()
|
||||
private fun MailboxItemUiModel.toMailboxState() = listOf(this).toMailboxState()
|
||||
|
||||
private fun List<MailboxUiItem>.toMailboxState(): MailboxState.Data =
|
||||
private fun List<MailboxItemUiModel>.toMailboxState(): MailboxState.Data =
|
||||
MailboxState.Data(this, isFreshData = false, shouldResetPosition = true)
|
||||
|
||||
private fun buildMailboxUiItem(
|
||||
|
@ -556,7 +556,7 @@ class MailboxViewModelTest : ArchTest, CoroutinesTest {
|
|||
labels: List<LabelChipUiModel> = emptyList(),
|
||||
recipients: String = "",
|
||||
isDraft: Boolean = false
|
||||
) = MailboxUiItem(
|
||||
) = MailboxItemUiModel(
|
||||
itemId = itemId,
|
||||
senderName = senderName,
|
||||
subject = subject,
|
||||
|
@ -587,7 +587,7 @@ class MailboxViewModelTest : ArchTest, CoroutinesTest {
|
|||
messages = emptyList()
|
||||
)
|
||||
|
||||
fun buildMailboxUiItem() = MailboxUiItem(
|
||||
fun buildMailboxUiItem() = MailboxItemUiModel(
|
||||
itemId = EMPTY_STRING,
|
||||
senderName = EMPTY_STRING,
|
||||
subject = EMPTY_STRING,
|
||||
|
|
|
@ -38,7 +38,7 @@ import ch.protonmail.android.mailbox.data.mapper.MessageRecipientToCorrespondent
|
|||
import ch.protonmail.android.mailbox.domain.model.Conversation
|
||||
import ch.protonmail.android.mailbox.domain.model.Correspondent
|
||||
import ch.protonmail.android.mailbox.domain.model.LabelContext
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxUiItem
|
||||
import ch.protonmail.android.mailbox.presentation.model.MailboxItemUiModel
|
||||
import ch.protonmail.android.mailbox.presentation.model.MessageData
|
||||
import io.mockk.coEvery
|
||||
import io.mockk.every
|
||||
|
@ -50,7 +50,7 @@ import me.proton.core.util.kotlin.EMPTY_STRING
|
|||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class MailboxUiItemMapperTest {
|
||||
class MailboxItemUiModelMapperTest {
|
||||
|
||||
private val contactsRepository: ContactsRepository = mockk {
|
||||
coEvery { findContactEmailByEmail(any()) } returns buildContactEmail()
|
||||
|
@ -59,7 +59,7 @@ class MailboxUiItemMapperTest {
|
|||
private val labelChipUiModelMapper: LabelChipUiModelMapper = mockk {
|
||||
every { toUiModels(any()) } returns emptyList()
|
||||
}
|
||||
private val mapper = MailboxUiItemMapper(
|
||||
private val mapper = MailboxItemUiModelMapper(
|
||||
contactsRepository = contactsRepository,
|
||||
messageRecipientToCorrespondentMapper = MessageRecipientToCorrespondentMapper(),
|
||||
labelChipUiModelMapper = labelChipUiModelMapper
|
||||
|
@ -95,7 +95,7 @@ class MailboxUiItemMapperTest {
|
|||
isForwarded = false
|
||||
isInline = false
|
||||
}
|
||||
val expected = MailboxUiItem(
|
||||
val expected = MailboxItemUiModel(
|
||||
itemId = TEST_ITEM_ID,
|
||||
senderName = TEST_SENDER_NAME,
|
||||
subject = TEST_SUBJECT,
|
||||
|
@ -118,7 +118,7 @@ class MailboxUiItemMapperTest {
|
|||
)
|
||||
|
||||
// when
|
||||
val result = mapper.toUiItem(message, allLabels = allLabels)
|
||||
val result = mapper.toUiModel(message, allLabels = allLabels)
|
||||
|
||||
// then
|
||||
assertEquals(expected, result)
|
||||
|
@ -132,7 +132,7 @@ class MailboxUiItemMapperTest {
|
|||
val expected = buildMailboxUiItem(messageData = buildMessageData())
|
||||
|
||||
// when
|
||||
val result = mapper.toUiItem(message, allLabels = emptyList())
|
||||
val result = mapper.toUiModel(message, allLabels = emptyList())
|
||||
|
||||
// then
|
||||
assertEquals(expected, result)
|
||||
|
@ -146,7 +146,7 @@ class MailboxUiItemMapperTest {
|
|||
val expected = buildMailboxUiItem(senderName = sender.emailAddress!!, messageData = buildMessageData())
|
||||
|
||||
// when
|
||||
val result = mapper.toUiItem(message, allLabels = emptyList())
|
||||
val result = mapper.toUiModel(message, allLabels = emptyList())
|
||||
|
||||
// then
|
||||
assertEquals(expected, result)
|
||||
|
@ -160,7 +160,7 @@ class MailboxUiItemMapperTest {
|
|||
val expected = buildMailboxUiItem(senderName = sender.name!!, messageData = buildMessageData())
|
||||
|
||||
// when
|
||||
val result = mapper.toUiItem(message, allLabels = emptyList())
|
||||
val result = mapper.toUiModel(message, allLabels = emptyList())
|
||||
|
||||
// then
|
||||
assertEquals(expected, result)
|
||||
|
@ -176,7 +176,7 @@ class MailboxUiItemMapperTest {
|
|||
val expected = buildMailboxUiItem(senderName = TEST_CONTACT_NAME, messageData = buildMessageData())
|
||||
|
||||
// when
|
||||
val result = mapper.toUiItem(message, allLabels = emptyList())
|
||||
val result = mapper.toUiModel(message, allLabels = emptyList())
|
||||
|
||||
// then
|
||||
assertEquals(expected, result)
|
||||
|
@ -210,7 +210,7 @@ class MailboxUiItemMapperTest {
|
|||
labels = conversationLabels.map { buildLabelContext(it.id) },
|
||||
messages = emptyList()
|
||||
)
|
||||
val expected = MailboxUiItem(
|
||||
val expected = MailboxItemUiModel(
|
||||
itemId = TEST_ITEM_ID,
|
||||
senderName = TEST_SENDER_NAME,
|
||||
subject = TEST_SUBJECT,
|
||||
|
@ -227,7 +227,7 @@ class MailboxUiItemMapperTest {
|
|||
)
|
||||
|
||||
// when
|
||||
val result = mapper.toUiItem(conversation, currentLabelId = currentLabelId, allLabels = allLabels)
|
||||
val result = mapper.toUiModel(conversation, currentLabelId = currentLabelId, allLabels = allLabels)
|
||||
|
||||
// then
|
||||
assertEquals(expected, result)
|
||||
|
@ -243,7 +243,7 @@ class MailboxUiItemMapperTest {
|
|||
val expected = buildMailboxUiItem(isStarred = true)
|
||||
|
||||
// when
|
||||
val result = mapper.toUiItem(conversation, currentLabelId = INBOX.asLabelId(), allLabels = emptyList())
|
||||
val result = mapper.toUiModel(conversation, currentLabelId = INBOX.asLabelId(), allLabels = emptyList())
|
||||
|
||||
// then
|
||||
assertEquals(expected, result)
|
||||
|
@ -257,7 +257,7 @@ class MailboxUiItemMapperTest {
|
|||
val expected = buildMailboxUiItem(senderName = sender.address)
|
||||
|
||||
// when
|
||||
val result = mapper.toUiItem(conversation, currentLabelId = INBOX.asLabelId(), allLabels = emptyList())
|
||||
val result = mapper.toUiModel(conversation, currentLabelId = INBOX.asLabelId(), allLabels = emptyList())
|
||||
|
||||
// then
|
||||
assertEquals(expected, result)
|
||||
|
@ -271,7 +271,7 @@ class MailboxUiItemMapperTest {
|
|||
val expected = buildMailboxUiItem(senderName = sender.name)
|
||||
|
||||
// when
|
||||
val result = mapper.toUiItem(conversation, currentLabelId = INBOX.asLabelId(), allLabels = emptyList())
|
||||
val result = mapper.toUiModel(conversation, currentLabelId = INBOX.asLabelId(), allLabels = emptyList())
|
||||
|
||||
// then
|
||||
assertEquals(expected, result)
|
||||
|
@ -288,7 +288,7 @@ class MailboxUiItemMapperTest {
|
|||
val expected = buildMailboxUiItem(senderName = TEST_CONTACT_NAME)
|
||||
|
||||
// when
|
||||
val result = mapper.toUiItem(conversation, currentLabelId = INBOX.asLabelId(), allLabels = emptyList())
|
||||
val result = mapper.toUiModel(conversation, currentLabelId = INBOX.asLabelId(), allLabels = emptyList())
|
||||
|
||||
// then
|
||||
assertEquals(expected, result)
|
||||
|
@ -307,7 +307,7 @@ class MailboxUiItemMapperTest {
|
|||
val expected = buildMailboxUiItem(isDraft = true)
|
||||
|
||||
// when
|
||||
val result = mapper.toUiItem(conversation, currentLabelId = INBOX.asLabelId(), allLabels = emptyList())
|
||||
val result = mapper.toUiModel(conversation, currentLabelId = INBOX.asLabelId(), allLabels = emptyList())
|
||||
|
||||
// then
|
||||
assertEquals(expected, result)
|
||||
|
@ -326,7 +326,7 @@ class MailboxUiItemMapperTest {
|
|||
val expected = buildMailboxUiItem(isDraft = false, messageCount = 2)
|
||||
|
||||
// when
|
||||
val result = mapper.toUiItem(conversation, currentLabelId = INBOX.asLabelId(), allLabels = emptyList())
|
||||
val result = mapper.toUiModel(conversation, currentLabelId = INBOX.asLabelId(), allLabels = emptyList())
|
||||
|
||||
// then
|
||||
assertEquals(expected, result)
|
||||
|
@ -346,7 +346,7 @@ class MailboxUiItemMapperTest {
|
|||
val expected = buildMailboxUiItem(lastMessageTimeMs = TEST_MESSAGE_TIME_MS, messageCount = 2)
|
||||
|
||||
// when
|
||||
val result = mapper.toUiItem(conversation, currentLabelId = SENT.asLabelId(), allLabels = emptyList())
|
||||
val result = mapper.toUiModel(conversation, currentLabelId = SENT.asLabelId(), allLabels = emptyList())
|
||||
|
||||
// then
|
||||
assertEquals(expected, result)
|
||||
|
@ -359,7 +359,7 @@ class MailboxUiItemMapperTest {
|
|||
val expected = buildMailboxUiItem(messageCount = null)
|
||||
|
||||
// when
|
||||
val result = mapper.toUiItem(conversation, currentLabelId = INBOX.asLabelId(), allLabels = emptyList())
|
||||
val result = mapper.toUiModel(conversation, currentLabelId = INBOX.asLabelId(), allLabels = emptyList())
|
||||
|
||||
// then
|
||||
assertEquals(expected, result)
|
||||
|
@ -414,7 +414,7 @@ class MailboxUiItemMapperTest {
|
|||
isStarred: Boolean = false,
|
||||
isDraft: Boolean = false,
|
||||
messageData: MessageData? = null
|
||||
) = MailboxUiItem(
|
||||
) = MailboxItemUiModel(
|
||||
itemId = EMPTY_STRING,
|
||||
senderName = senderName,
|
||||
subject = EMPTY_STRING,
|
Loading…
Reference in New Issue