diff --git a/core/network/src/commonMain/kotlin/com/stslex/core/network/clients/match/client/MockMatchClientImpl.kt b/core/network/src/commonMain/kotlin/com/stslex/core/network/clients/match/client/MockMatchClientImpl.kt index a34d080d..64460b22 100644 --- a/core/network/src/commonMain/kotlin/com/stslex/core/network/clients/match/client/MockMatchClientImpl.kt +++ b/core/network/src/commonMain/kotlin/com/stslex/core/network/clients/match/client/MockMatchClientImpl.kt @@ -35,7 +35,8 @@ class MockMatchClientImpl : MatchClient { description = it.description, status = it.status, participants = it.participants, - isCreator = it.isCreator, + creatorUuid = "creatorUuid", + coverUrl = "coverUrl", expiresAt = it.expiresAt ) }, @@ -70,10 +71,11 @@ class MockMatchClientImpl : MatchClient { description = "description$index", status = if (index % 2 == 0) MatchStatusResponse.PENDING else MatchStatusResponse.ACTIVE, participants = createMatchUsers(index), - isCreator = index % 2 == 0, + creatorUuid = "creatorUuid", createdAt = created, updatedAt = updated, expiresAt = expires, + coverUrl = "coverUrl" ) } diff --git a/core/network/src/commonMain/kotlin/com/stslex/core/network/clients/match/model/request/MatchCreateRequest.kt b/core/network/src/commonMain/kotlin/com/stslex/core/network/clients/match/model/request/MatchCreateRequest.kt index aab6781d..1ccddc97 100644 --- a/core/network/src/commonMain/kotlin/com/stslex/core/network/clients/match/model/request/MatchCreateRequest.kt +++ b/core/network/src/commonMain/kotlin/com/stslex/core/network/clients/match/model/request/MatchCreateRequest.kt @@ -13,4 +13,6 @@ data class MatchCreateRequest( val expiresAt: String, @SerialName("participants_uuid") val participantsUuid: List, + @SerialName("cover_url") + val coverUrl: String ) \ No newline at end of file diff --git a/core/network/src/commonMain/kotlin/com/stslex/core/network/clients/match/model/response/MatchDetailResponse.kt b/core/network/src/commonMain/kotlin/com/stslex/core/network/clients/match/model/response/MatchDetailResponse.kt index 90fb4036..3f8035ce 100644 --- a/core/network/src/commonMain/kotlin/com/stslex/core/network/clients/match/model/response/MatchDetailResponse.kt +++ b/core/network/src/commonMain/kotlin/com/stslex/core/network/clients/match/model/response/MatchDetailResponse.kt @@ -15,12 +15,14 @@ data class MatchDetailResponse( val status: MatchStatusResponse = MatchStatusResponse.PENDING, @SerialName("participants") val participants: List, - @SerialName("is_creator") - val isCreator: Boolean, + @SerialName("creator_uuid") + val creatorUuid: String, @SerialName("created_at") val createdAt: Long, @SerialName("updated_at") val updatedAt: Long, @SerialName("expires_at") val expiresAt: Long, + @SerialName("cover_url") + val coverUrl: String, ) diff --git a/core/network/src/commonMain/kotlin/com/stslex/core/network/clients/match/model/response/MatchResponse.kt b/core/network/src/commonMain/kotlin/com/stslex/core/network/clients/match/model/response/MatchResponse.kt index c28f89b1..65a91bdf 100644 --- a/core/network/src/commonMain/kotlin/com/stslex/core/network/clients/match/model/response/MatchResponse.kt +++ b/core/network/src/commonMain/kotlin/com/stslex/core/network/clients/match/model/response/MatchResponse.kt @@ -14,10 +14,12 @@ data class MatchResponse( val description: String, @SerialName("status") val status: MatchStatusResponse, + @SerialName("creator_uuid") + val creatorUuid: String, @SerialName("participants") val participants: List, - @SerialName("is_creator") - val isCreator: Boolean, @SerialName("expires_at") val expiresAt: Long, + @SerialName("cover_url") + val coverUrl: String, ) : PagingCoreItem diff --git a/feature/match/src/commonMain/kotlin/com/stslex/feature/match/data/model/MatchDataMapper.kt b/feature/match/src/commonMain/kotlin/com/stslex/feature/match/data/model/MatchDataMapper.kt index aa7eb523..6f026b7d 100644 --- a/feature/match/src/commonMain/kotlin/com/stslex/feature/match/data/model/MatchDataMapper.kt +++ b/feature/match/src/commonMain/kotlin/com/stslex/feature/match/data/model/MatchDataMapper.kt @@ -5,13 +5,15 @@ import com.stslex.core.network.clients.match.model.response.MatchResponse import com.stslex.core.network.clients.match.model.response.MatchStatusResponse import com.stslex.core.network.clients.match.model.response.MatchUserResponse -internal suspend fun MatchResponse.toData() = MatchDataModel( +internal suspend fun MatchResponse.toData( + userUUID: String +) = MatchDataModel( uuid = uuid, title = title, description = description, status = status.toData(), participants = participants.asyncMap { it.toData() }, - isCreator = isCreator, + isCreator = userUUID == creatorUuid, expiresAt = expiresAt, ) diff --git a/feature/match/src/commonMain/kotlin/com/stslex/feature/match/data/repository/MatchRepositoryImpl.kt b/feature/match/src/commonMain/kotlin/com/stslex/feature/match/data/repository/MatchRepositoryImpl.kt index c2b4f97a..7bcf919f 100644 --- a/feature/match/src/commonMain/kotlin/com/stslex/feature/match/data/repository/MatchRepositoryImpl.kt +++ b/feature/match/src/commonMain/kotlin/com/stslex/feature/match/data/repository/MatchRepositoryImpl.kt @@ -2,13 +2,15 @@ package com.stslex.feature.match.data.repository import com.stslex.core.core.paging.PagingResponse import com.stslex.core.core.paging.pagingMap +import com.stslex.core.database.store.UserStore import com.stslex.core.network.clients.match.client.MatchClient import com.stslex.core.network.model.PagingRequest import com.stslex.feature.match.data.model.MatchDataModel import com.stslex.feature.match.data.model.toData class MatchRepositoryImpl( - private val client: MatchClient + private val client: MatchClient, + private val userStore: UserStore ) : MatchRepository { override suspend fun getMatches( @@ -25,5 +27,7 @@ class MatchRepositoryImpl( query = query ) ) - .pagingMap { it.toData() } + .pagingMap { + it.toData(userUUID = userStore.uuid) + } } \ No newline at end of file diff --git a/feature/match/src/commonMain/kotlin/com/stslex/feature/match/di/MatchModule.kt b/feature/match/src/commonMain/kotlin/com/stslex/feature/match/di/MatchModule.kt index d3c3e07a..65a67e28 100644 --- a/feature/match/src/commonMain/kotlin/com/stslex/feature/match/di/MatchModule.kt +++ b/feature/match/src/commonMain/kotlin/com/stslex/feature/match/di/MatchModule.kt @@ -11,7 +11,12 @@ import com.stslex.feature.match.ui.store.MatchStoreImpl import org.koin.dsl.module val featureMatchModule = module { - factory { MatchRepositoryImpl(client = get()) } + factory { + MatchRepositoryImpl( + client = get(), + userStore = get() + ) + } factory { MatchInteractorImpl( repository = get(),