Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove duplicated legalHoldStatus field from ConversationDetails [WPB-4568] #2336

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import com.wire.kalium.logic.data.id.PlainId
import com.wire.kalium.logic.data.id.TeamId
import com.wire.kalium.logic.data.message.MessagePreview
import com.wire.kalium.logic.data.message.UnreadEventType
import com.wire.kalium.logic.data.user.LegalHoldStatus
import com.wire.kalium.logic.data.user.OtherUser
import com.wire.kalium.logic.data.user.User
import com.wire.kalium.logic.data.user.UserId
Expand Down Expand Up @@ -288,15 +287,13 @@ sealed class ConversationDetails(open val conversation: Conversation) {
data class OneOne(
override val conversation: Conversation,
val otherUser: OtherUser,
val legalHoldStatus: LegalHoldStatus,
val userType: UserType,
val unreadEventCount: UnreadEventCount,
val lastMessage: MessagePreview?
) : ConversationDetails(conversation)

data class Group(
override val conversation: Conversation,
val legalHoldStatus: LegalHoldStatus,
val hasOngoingCall: Boolean = false,
val unreadEventCount: UnreadEventCount,
val lastMessage: MessagePreview?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import com.wire.kalium.logic.data.message.MessagePreview
import com.wire.kalium.logic.data.user.AvailabilityStatusMapper
import com.wire.kalium.logic.data.user.BotService
import com.wire.kalium.logic.data.user.Connection
import com.wire.kalium.logic.data.user.LegalHoldStatus
import com.wire.kalium.logic.data.user.OtherUser
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.data.user.toModel
Expand Down Expand Up @@ -220,7 +219,6 @@ internal class ConversationMapperImpl(
supportedProtocols = userSupportedProtocols?.map { it.toModel() }?.toSet(),
activeOneOnOneConversationId = userActiveOneOnOneConversationId?.toModel()
),
legalHoldStatus = LegalHoldStatus.DISABLED,
userType = domainUserTypeMapper.fromUserTypeEntity(userType),
unreadEventCount = unreadEventCount ?: mapOf(),
lastMessage = lastMessage
Expand All @@ -230,7 +228,6 @@ internal class ConversationMapperImpl(
ConversationEntity.Type.GROUP -> {
ConversationDetails.Group(
conversation = fromDaoModel(daoModel),
legalHoldStatus = LegalHoldStatus.DISABLED,
hasOngoingCall = callStatus != null, // todo: we can do better!
unreadEventCount = unreadEventCount ?: mapOf(),
lastMessage = lastMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import com.wire.kalium.logic.data.conversation.ClientId
import com.wire.kalium.logic.data.conversation.Conversation
import com.wire.kalium.logic.data.conversation.ConversationDetails
import com.wire.kalium.logic.data.conversation.ConversationRepository
import com.wire.kalium.logic.data.user.LegalHoldStatus
import com.wire.kalium.logic.data.conversation.JoinSubconversationUseCase
import com.wire.kalium.logic.data.conversation.LeaveSubconversationUseCase
import com.wire.kalium.logic.data.conversation.MLSConversationRepository
import com.wire.kalium.logic.data.conversation.SubconversationRepository
import com.wire.kalium.logic.data.id.ConversationId
Expand All @@ -45,8 +46,6 @@ import com.wire.kalium.logic.data.team.TeamRepository
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.data.user.UserRepository
import com.wire.kalium.logic.data.user.type.UserType
import com.wire.kalium.logic.data.conversation.JoinSubconversationUseCase
import com.wire.kalium.logic.data.conversation.LeaveSubconversationUseCase
import com.wire.kalium.logic.framework.TestConversation
import com.wire.kalium.logic.framework.TestTeam
import com.wire.kalium.logic.framework.TestUser
Expand Down Expand Up @@ -172,7 +171,6 @@ class CallRepositoryTest {
Either.Right(
ConversationDetails.Group(
Arrangement.groupConversation,
LegalHoldStatus.ENABLED,
false,
lastMessage = null,
isSelfUserMember = true,
Expand Down Expand Up @@ -214,7 +212,6 @@ class CallRepositoryTest {
Either.Right(
ConversationDetails.Group(
Arrangement.groupConversation,
LegalHoldStatus.ENABLED,
lastMessage = null,
isSelfUserMember = true,
isSelfUserCreator = true,
Expand Down Expand Up @@ -271,7 +268,6 @@ class CallRepositoryTest {
Either.Right(
ConversationDetails.Group(
Arrangement.groupConversation,
LegalHoldStatus.ENABLED,
lastMessage = null,
isSelfUserMember = true,
isSelfUserCreator = true,
Expand Down Expand Up @@ -317,7 +313,6 @@ class CallRepositoryTest {
Either.Right(
ConversationDetails.Group(
Arrangement.groupConversation,
LegalHoldStatus.ENABLED,
lastMessage = null,
isSelfUserMember = true,
isSelfUserCreator = true,
Expand Down Expand Up @@ -377,7 +372,6 @@ class CallRepositoryTest {
Either.Right(
ConversationDetails.Group(
Arrangement.groupConversation,
LegalHoldStatus.ENABLED,
lastMessage = null,
isSelfUserMember = true,
isSelfUserCreator = true,
Expand Down Expand Up @@ -1742,7 +1736,6 @@ class CallRepositoryTest {
val oneOnOneConversationDetails = ConversationDetails.OneOne(
conversation = oneOnOneConversation,
otherUser = TestUser.OTHER,
legalHoldStatus = LegalHoldStatus.ENABLED,
userType = UserType.INTERNAL,
lastMessage = null,
unreadEventCount = emptyMap()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.wire.kalium.logic.feature.call.usecase

import com.wire.kalium.logic.StorageFailure
import com.wire.kalium.logic.data.call.Call
import com.wire.kalium.logic.data.call.CallStatus
import com.wire.kalium.logic.data.conversation.Conversation
import com.wire.kalium.logic.data.conversation.ConversationDetails
import com.wire.kalium.logic.data.user.LegalHoldStatus
import com.wire.kalium.logic.data.conversation.MutedConversationStatus
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.id.TeamId
Expand All @@ -14,8 +15,6 @@ import com.wire.kalium.logic.data.user.UserAssetId
import com.wire.kalium.logic.data.user.UserAvailabilityStatus
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.data.user.type.UserType
import com.wire.kalium.logic.data.call.Call
import com.wire.kalium.logic.data.call.CallStatus
import com.wire.kalium.logic.functional.Either
import com.wire.kalium.logic.util.arrangement.repository.CallRepositoryArrangement
import com.wire.kalium.logic.util.arrangement.repository.CallRepositoryArrangementImpl
Expand Down Expand Up @@ -242,7 +241,6 @@ class EndCallOnConversationChangeUseCaseTest {

private val groupConversationDetail = ConversationDetails.Group(
conversation = conversation,
legalHoldStatus = LegalHoldStatus.ENABLED,
hasOngoingCall = true,
unreadEventCount = mapOf(),
lastMessage = null,
Expand All @@ -253,7 +251,6 @@ class EndCallOnConversationChangeUseCaseTest {

private val oneOnOneConversationDetail = ConversationDetails.OneOne(
conversation = conversation,
legalHoldStatus = LegalHoldStatus.ENABLED,
otherUser = otherUser,
unreadEventCount = mapOf(),
lastMessage = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import com.wire.kalium.logic.StorageFailure
import com.wire.kalium.logic.data.conversation.Conversation
import com.wire.kalium.logic.data.conversation.ConversationDetails
import com.wire.kalium.logic.data.conversation.ConversationRepository
import com.wire.kalium.logic.data.user.LegalHoldStatus
import com.wire.kalium.logic.framework.TestConversation
import com.wire.kalium.logic.functional.Either
import io.mockative.Mock
Expand Down Expand Up @@ -77,7 +76,6 @@ class ObserveConversationDetailsUseCaseTest {
Either.Right(
ConversationDetails.Group(
conversation,
LegalHoldStatus.DISABLED,
lastMessage = null,
isSelfUserMember = true,
isSelfUserCreator = true,
Expand All @@ -88,7 +86,6 @@ class ObserveConversationDetailsUseCaseTest {
Either.Right(
ConversationDetails.Group(
conversation.copy(name = "New Name"),
LegalHoldStatus.DISABLED,
lastMessage = null,
isSelfUserMember = true,
isSelfUserCreator = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import com.wire.kalium.logic.StorageFailure
import com.wire.kalium.logic.data.conversation.Conversation
import com.wire.kalium.logic.data.conversation.ConversationDetails
import com.wire.kalium.logic.data.conversation.ConversationRepository
import com.wire.kalium.logic.data.user.LegalHoldStatus
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.user.type.UserType
import com.wire.kalium.logic.framework.TestConversation
Expand Down Expand Up @@ -65,7 +64,6 @@ class ObserveConversationListDetailsUseCaseTest {
val groupConversationDetails =
ConversationDetails.Group(
groupConversation,
LegalHoldStatus.DISABLED,
lastMessage = null,
isSelfUserMember = true,
isSelfUserCreator = true,
Expand Down Expand Up @@ -102,7 +100,6 @@ class ObserveConversationListDetailsUseCaseTest {
val groupConversationDetails1 =
ConversationDetails.Group(
groupConversation1,
LegalHoldStatus.DISABLED,
lastMessage = null,
isSelfUserMember = true,
isSelfUserCreator = true,
Expand All @@ -112,7 +109,6 @@ class ObserveConversationListDetailsUseCaseTest {
val groupConversationDetails2 =
ConversationDetails.Group(
groupConversation2,
LegalHoldStatus.DISABLED,
lastMessage = null,
isSelfUserMember = true,
isSelfUserCreator = true,
Expand Down Expand Up @@ -149,7 +145,6 @@ class ObserveConversationListDetailsUseCaseTest {
val selfConversationDetails = ConversationDetails.Self(selfConversation)
val groupConversationDetails = ConversationDetails.Group(
conversation = groupConversation,
legalHoldStatus = LegalHoldStatus.DISABLED,
lastMessage = null,
isSelfUserMember = true,
isSelfUserCreator = true,
Expand Down Expand Up @@ -187,7 +182,6 @@ class ObserveConversationListDetailsUseCaseTest {
val groupConversationUpdates = listOf(
ConversationDetails.Group(
groupConversation,
LegalHoldStatus.DISABLED,
lastMessage = null,
isSelfUserMember = true,
isSelfUserCreator = true,
Expand All @@ -199,15 +193,13 @@ class ObserveConversationListDetailsUseCaseTest {
val firstOneOnOneDetails = ConversationDetails.OneOne(
oneOnOneConversation,
TestUser.OTHER,
LegalHoldStatus.ENABLED,
UserType.INTERNAL,
lastMessage = null,
unreadEventCount = emptyMap()
)
val secondOneOnOneDetails = ConversationDetails.OneOne(
oneOnOneConversation,
TestUser.OTHER.copy(name = "New User Name"),
LegalHoldStatus.DISABLED,
UserType.INTERNAL,
lastMessage = null,
unreadEventCount = emptyMap()
Expand Down Expand Up @@ -244,7 +236,6 @@ class ObserveConversationListDetailsUseCaseTest {
val fetchArchivedConversations = false
val groupConversationDetails = ConversationDetails.Group(
groupConversation,
LegalHoldStatus.DISABLED,
lastMessage = null,
isSelfUserMember = true,
isSelfUserCreator = true,
Expand Down Expand Up @@ -282,7 +273,6 @@ class ObserveConversationListDetailsUseCaseTest {
val fetchArchivedConversations = false
val groupConversationDetails = ConversationDetails.Group(
groupConversation,
LegalHoldStatus.DISABLED,
lastMessage = null,
isSelfUserMember = true,
isSelfUserCreator = true,
Expand Down Expand Up @@ -314,7 +304,6 @@ class ObserveConversationListDetailsUseCaseTest {

val groupConversationDetails = ConversationDetails.Group(
groupConversation,
LegalHoldStatus.DISABLED,
lastMessage = null,
isSelfUserMember = true,
isSelfUserCreator = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package com.wire.kalium.logic.framework
import com.wire.kalium.logic.data.conversation.Conversation
import com.wire.kalium.logic.data.conversation.Conversation.ProtocolInfo
import com.wire.kalium.logic.data.conversation.ConversationDetails
import com.wire.kalium.logic.data.user.LegalHoldStatus
import com.wire.kalium.logic.data.user.type.UserType

object TestConversationDetails {
Expand All @@ -40,15 +39,13 @@ object TestConversationDetails {
val CONVERSATION_ONE_ONE = ConversationDetails.OneOne(
TestConversation.ONE_ON_ONE(),
TestUser.OTHER,
LegalHoldStatus.DISABLED,
UserType.EXTERNAL,
lastMessage = null,
unreadEventCount = emptyMap()
)

val CONVERSATION_GROUP = ConversationDetails.Group(
conversation = TestConversation.GROUP(),
legalHoldStatus = LegalHoldStatus.ENABLED,
lastMessage = null,
isSelfUserCreator = true,
isSelfUserMember = true,
Expand Down
Loading