Skip to content

Commit

Permalink
fix: crash conversation mapper [WPB-5199] (#2203)
Browse files Browse the repository at this point in the history
* fix: crash in conversation mapper

* detekt fix

* reverted call repository changes
  • Loading branch information
Garzas authored Nov 9, 2023
1 parent b8efc41 commit e7e24ea
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ import com.wire.kalium.logic.data.id.GroupID
import com.wire.kalium.logic.data.id.IdMapper
import com.wire.kalium.logic.data.id.NetworkQualifiedId
import com.wire.kalium.logic.data.id.QualifiedID
import com.wire.kalium.logic.data.id.SelfTeamIdProvider
import com.wire.kalium.logic.data.id.TeamId
import com.wire.kalium.logic.data.id.toApi
import com.wire.kalium.logic.data.id.toCrypto
import com.wire.kalium.logic.data.id.toDao
import com.wire.kalium.logic.data.id.toModel
import com.wire.kalium.logic.data.message.MessageMapper
import com.wire.kalium.logic.data.message.SelfDeletionTimer
import com.wire.kalium.logic.data.message.UnreadEventType
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.di.MapperProvider
import com.wire.kalium.logic.data.id.SelfTeamIdProvider
import com.wire.kalium.logic.data.message.SelfDeletionTimer
import com.wire.kalium.logic.functional.Either
import com.wire.kalium.logic.functional.flatMap
import com.wire.kalium.logic.functional.fold
Expand Down Expand Up @@ -526,6 +526,7 @@ internal class ConversationDataSource internal constructor(
conversationDAO.getConversationIds(type.toDAO(), protocol.toDao(), teamId?.value)
.map { it.toModel() }
}

override suspend fun getTeamConversationIdsReadyToCompleteMigration(teamId: TeamId): Either<StorageFailure, List<QualifiedID>> =
wrapStorageRequest {
conversationDAO.getTeamConversationIdsReadyToCompleteMigration(teamId.value)
Expand All @@ -539,7 +540,16 @@ internal class ConversationDataSource internal constructor(
conversationDAO.observeGetConversationByQualifiedID(conversationID.toDao())
.wrapStorageRequest()
// TODO we don't need last message and unread count here, we should discuss to divide model for list and for details
.mapRight { conversationMapper.fromDaoModelToDetails(it, null, mapOf()) }
.map { eitherConversationView ->
eitherConversationView.flatMap {
try {
Either.Right(conversationMapper.fromDaoModelToDetails(it, null, mapOf()))
} catch (error: IllegalArgumentException) {
kaliumLogger.e("require field in conversation Details", error)
Either.Left(StorageFailure.DataNotFound)
}
}
}
.distinctUntilChanged()

override suspend fun fetchConversation(conversationID: ConversationId): Either<CoreFailure, Unit> {
Expand Down

0 comments on commit e7e24ea

Please sign in to comment.