diff --git a/androidApp/src/main/java/fr/paug/androidmakers/ui/components/agenda/AgendaLayoutViewModel.kt b/androidApp/src/main/java/fr/paug/androidmakers/ui/components/agenda/AgendaLayoutViewModel.kt index 31418060..d9279fc6 100644 --- a/androidApp/src/main/java/fr/paug/androidmakers/ui/components/agenda/AgendaLayoutViewModel.kt +++ b/androidApp/src/main/java/fr/paug/androidmakers/ui/components/agenda/AgendaLayoutViewModel.kt @@ -28,7 +28,7 @@ class AgendaLayoutViewModel( val state: StateFlow = combine( roomsRepository.getRooms() .map { rooms -> - rooms/*.recover { emptyList() }*/ + rooms.recover { emptyList() } .getOrThrow() }, sessionFilters, diff --git a/androidApp/src/main/java/fr/paug/androidmakers/ui/components/agenda/AgendaPagerViewModel.kt b/androidApp/src/main/java/fr/paug/androidmakers/ui/components/agenda/AgendaPagerViewModel.kt index 73f31beb..403b1a92 100644 --- a/androidApp/src/main/java/fr/paug/androidmakers/ui/components/agenda/AgendaPagerViewModel.kt +++ b/androidApp/src/main/java/fr/paug/androidmakers/ui/components/agenda/AgendaPagerViewModel.kt @@ -1,6 +1,5 @@ package fr.paug.androidmakers.ui.components.agenda -import at.asitplus.KmmResult import com.androidmakers.ui.common.LceViewModel import fr.androidmakers.domain.interactor.GetAgendaUseCase import fr.androidmakers.domain.interactor.GetFavoriteSessionsUseCase @@ -16,7 +15,7 @@ class AgendaPagerViewModel( private val setSessionBookmarkUseCase: SetSessionBookmarkUseCase, private val getFavoriteSessionsUseCase: GetFavoriteSessionsUseCase ) : LceViewModel() { - override fun produce(): Flow> { + override fun produce(): Flow> { return getAgendaUseCase() } diff --git a/androidApp/src/main/java/fr/paug/androidmakers/ui/components/session/SessionDetailViewModel.kt b/androidApp/src/main/java/fr/paug/androidmakers/ui/components/session/SessionDetailViewModel.kt index 484f711f..d290805d 100644 --- a/androidApp/src/main/java/fr/paug/androidmakers/ui/components/session/SessionDetailViewModel.kt +++ b/androidApp/src/main/java/fr/paug/androidmakers/ui/components/session/SessionDetailViewModel.kt @@ -67,7 +67,7 @@ class SessionDetailViewModel( private suspend fun getSpeakers(session: Session): List { val allSpeakers = speakersRepository.getSpeakers().firstOrNull() - //?.recover { emptyList() } + ?.recover { emptyList() } ?.getOrThrow() ?: return emptyList() diff --git a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/FlowExtensions.kt b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/FlowExtensions.kt index b7985f76..891d82a2 100644 --- a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/FlowExtensions.kt +++ b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/FlowExtensions.kt @@ -1,12 +1,11 @@ package fr.androidmakers.store.graphql -import at.asitplus.KmmResult import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.map -internal fun Flow.toResultFlow(): Flow> = this.map { - KmmResult.success(it) +internal fun Flow.toResultFlow(): Flow> = this.map { + Result.success(it) }.catch { - emit(KmmResult.failure(it)) + emit(Result.failure(it)) } diff --git a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/PartnersGraphQLRepository.kt b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/PartnersGraphQLRepository.kt index fbce361a..8c97bd79 100644 --- a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/PartnersGraphQLRepository.kt +++ b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/PartnersGraphQLRepository.kt @@ -1,6 +1,5 @@ package fr.androidmakers.store.graphql -import at.asitplus.KmmResult import com.apollographql.apollo3.ApolloClient import com.apollographql.apollo3.cache.normalized.FetchPolicy import com.apollographql.apollo3.cache.normalized.fetchPolicy @@ -12,7 +11,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map class PartnersGraphQLRepository(private val apolloClient: ApolloClient): PartnersRepository { - override fun getPartners(): Flow>> { + override fun getPartners(): Flow>> { return apolloClient.query(GetPartnerGroupsQuery()) .fetchPolicy(FetchPolicy.CacheAndNetwork) .watch().map { diff --git a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/RoomsGraphQLRepository.kt b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/RoomsGraphQLRepository.kt index 6c6845f9..8d4c39ab 100644 --- a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/RoomsGraphQLRepository.kt +++ b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/RoomsGraphQLRepository.kt @@ -1,6 +1,5 @@ package fr.androidmakers.store.graphql -import at.asitplus.KmmResult import com.apollographql.apollo3.ApolloClient import com.apollographql.apollo3.cache.normalized.FetchPolicy import com.apollographql.apollo3.cache.normalized.fetchPolicy @@ -11,13 +10,13 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map class RoomsGraphQLRepository(private val apolloClient: ApolloClient): RoomsRepository { - override fun getRoom(id: String): Flow> { + override fun getRoom(id: String): Flow> { return getRooms().map { it.map { it.singleOrNull { it.id == id } ?: error("Not Room") } } } - override fun getRooms(): Flow>> { + override fun getRooms(): Flow>> { return apolloClient.query(GetRoomsQuery()) .fetchPolicy(FetchPolicy.NetworkFirst) .watch() diff --git a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/SessionsGraphQLRepository.kt b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/SessionsGraphQLRepository.kt index 1d42b279..86774004 100644 --- a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/SessionsGraphQLRepository.kt +++ b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/SessionsGraphQLRepository.kt @@ -1,6 +1,5 @@ package fr.androidmakers.store.graphql -import at.asitplus.KmmResult import com.apollographql.apollo3.ApolloClient import com.apollographql.apollo3.api.Mutation import com.apollographql.apollo3.cache.normalized.FetchPolicy @@ -51,7 +50,7 @@ class SessionsGraphQLRepository(private val apolloClient: ApolloClient): Session } } - override fun getSession(id: String): Flow> { + override fun getSession(id: String): Flow> { return apolloClient.query(GetSessionQuery(id)) .fetchPolicy(FetchPolicy.CacheAndNetwork) .watch().map { @@ -60,7 +59,7 @@ class SessionsGraphQLRepository(private val apolloClient: ApolloClient): Session .toResultFlow() } - override fun getBookmarks(uid: String): Flow>> { + override fun getBookmarks(uid: String): Flow>> { return apolloClient.query(BookmarksQuery()) .fetchPolicy(FetchPolicy.NetworkOnly) .refetchPolicy(FetchPolicy.CacheOnly) @@ -91,7 +90,7 @@ class SessionsGraphQLRepository(private val apolloClient: ApolloClient): Session return response.data != null } - override fun getSessions(): Flow>> { + override fun getSessions(): Flow>> { return apolloClient.query(GetSessionsQuery()) .fetchPolicy(FetchPolicy.CacheAndNetwork) .watch() diff --git a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/SpeakersGraphQLRepository.kt b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/SpeakersGraphQLRepository.kt index abf2f3ff..6f6da64c 100644 --- a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/SpeakersGraphQLRepository.kt +++ b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/SpeakersGraphQLRepository.kt @@ -1,6 +1,5 @@ package fr.androidmakers.store.graphql -import at.asitplus.KmmResult import com.apollographql.apollo3.ApolloClient import com.apollographql.apollo3.cache.normalized.FetchPolicy import com.apollographql.apollo3.cache.normalized.fetchPolicy @@ -12,13 +11,13 @@ import kotlinx.coroutines.flow.map class SpeakersGraphQLRepository(private val apolloClient: ApolloClient): SpeakersRepository { - override fun getSpeakers(): Flow>> { + override fun getSpeakers(): Flow>> { return apolloClient.query(GetSpeakersQuery()).watch().map { it.dataAssertNoErrors.speakers.map { it.speakerDetails.toSpeaker() } }.toResultFlow() } - override fun getSpeaker(id: String): Flow> { + override fun getSpeaker(id: String): Flow> { return apolloClient.query(GetSpeakersQuery()) .fetchPolicy(FetchPolicy.CacheAndNetwork) .watch().map { diff --git a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/VenueGraphQLRepository.kt b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/VenueGraphQLRepository.kt index 074fcf87..9a3ea260 100644 --- a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/VenueGraphQLRepository.kt +++ b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/VenueGraphQLRepository.kt @@ -1,6 +1,5 @@ package fr.androidmakers.store.graphql -import at.asitplus.KmmResult import com.apollographql.apollo3.ApolloClient import com.apollographql.apollo3.cache.normalized.FetchPolicy import com.apollographql.apollo3.cache.normalized.fetchPolicy @@ -11,7 +10,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map class VenueGraphQLRepository(private val apolloClient: ApolloClient): VenueRepository { - override fun getVenue(id: String): Flow> { + override fun getVenue(id: String): Flow> { return apolloClient.query(GetVenueQuery(id)) .fetchPolicy(FetchPolicy.CacheAndNetwork) .watch().map { diff --git a/shared/domain/build.gradle.kts b/shared/domain/build.gradle.kts index 1a24e280..2559f3af 100644 --- a/shared/domain/build.gradle.kts +++ b/shared/domain/build.gradle.kts @@ -20,10 +20,6 @@ kotlin { commonMain.dependencies { implementation(libs.kotlinx.coroutines.core) api(libs.kotlinx.datetime) - - // Temporary dependency to handle the fact that swift doesnt support Kotlin Result - // It will be removed when we will merge the viewmodels or go for Compose MP - api("at.asitplus:kmmresult:1.5.4") } } } diff --git a/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/interactor/GetAgendaUseCase.kt b/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/interactor/GetAgendaUseCase.kt index 0076cdc6..6a661ada 100644 --- a/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/interactor/GetAgendaUseCase.kt +++ b/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/interactor/GetAgendaUseCase.kt @@ -1,6 +1,5 @@ package fr.androidmakers.domain.interactor -import at.asitplus.KmmResult import fr.androidmakers.domain.model.Agenda import fr.androidmakers.domain.repo.RoomsRepository import fr.androidmakers.domain.repo.SessionsRepository @@ -13,7 +12,7 @@ class GetAgendaUseCase( private val speakersRepository: SpeakersRepository, private val roomsRepository: RoomsRepository, ) { - operator fun invoke(): Flow> { + operator fun invoke(): Flow> { return combine( sessionsRepository.getSessions(), roomsRepository.getRooms(), @@ -22,18 +21,18 @@ class GetAgendaUseCase( sessions.exceptionOrNull()?.let { it.printStackTrace() - return@combine KmmResult.failure(it) + return@combine Result.failure(it) } rooms.exceptionOrNull()?.let { it.printStackTrace() - return@combine KmmResult.failure(it) + return@combine Result.failure(it) } speakers.exceptionOrNull()?.let { it.printStackTrace() - return@combine KmmResult.failure(it) + return@combine Result.failure(it) } - KmmResult.success( + Result.success( Agenda( sessions = sessions.getOrThrow().associateBy { it.id }, rooms = rooms.getOrThrow().associateBy { it.id }, diff --git a/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/PartnersRepository.kt b/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/PartnersRepository.kt index d0dc570f..7312f729 100644 --- a/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/PartnersRepository.kt +++ b/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/PartnersRepository.kt @@ -1,9 +1,8 @@ package fr.androidmakers.domain.repo -import at.asitplus.KmmResult import fr.androidmakers.domain.model.PartnerGroup import kotlinx.coroutines.flow.Flow interface PartnersRepository { - fun getPartners(): Flow>> + fun getPartners(): Flow>> } diff --git a/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/RoomsRepository.kt b/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/RoomsRepository.kt index 3f006a76..60a50226 100644 --- a/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/RoomsRepository.kt +++ b/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/RoomsRepository.kt @@ -1,12 +1,11 @@ package fr.androidmakers.domain.repo -import at.asitplus.KmmResult import fr.androidmakers.domain.model.Room import kotlinx.coroutines.flow.Flow interface RoomsRepository { - fun getRoom(id: String): Flow> + fun getRoom(id: String): Flow> - fun getRooms(): Flow>> + fun getRooms(): Flow>> } diff --git a/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/SessionsRepository.kt b/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/SessionsRepository.kt index 9f5b2ed5..87ace0a2 100644 --- a/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/SessionsRepository.kt +++ b/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/SessionsRepository.kt @@ -1,15 +1,14 @@ package fr.androidmakers.domain.repo -import at.asitplus.KmmResult import fr.androidmakers.domain.model.Session import kotlinx.coroutines.flow.Flow interface SessionsRepository { - fun getSession(id: String): Flow> + fun getSession(id: String): Flow> - fun getSessions(): Flow>> + fun getSessions(): Flow>> - fun getBookmarks(userId: String): Flow>> + fun getBookmarks(userId: String): Flow>> suspend fun setBookmark(userId: String, sessionId: String, value: Boolean) } diff --git a/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/SpeakersRepository.kt b/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/SpeakersRepository.kt index c2005671..2a0eceb2 100644 --- a/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/SpeakersRepository.kt +++ b/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/SpeakersRepository.kt @@ -1,12 +1,11 @@ package fr.androidmakers.domain.repo -import at.asitplus.KmmResult import fr.androidmakers.domain.model.Speaker import kotlinx.coroutines.flow.Flow interface SpeakersRepository { - fun getSpeaker(id: String): Flow> + fun getSpeaker(id: String): Flow> - fun getSpeakers(): Flow>> + fun getSpeakers(): Flow>> } diff --git a/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/VenueRepository.kt b/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/VenueRepository.kt index 3c33f1f5..c0064e21 100644 --- a/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/VenueRepository.kt +++ b/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/repo/VenueRepository.kt @@ -1,9 +1,8 @@ package fr.androidmakers.domain.repo -import at.asitplus.KmmResult import fr.androidmakers.domain.model.Venue import kotlinx.coroutines.flow.Flow interface VenueRepository { - fun getVenue(id: String): Flow> + fun getVenue(id: String): Flow> } diff --git a/shared/src/commonMain/kotlin/TestCla.kt b/shared/src/commonMain/kotlin/TestCla.kt deleted file mode 100644 index 02b07284..00000000 --- a/shared/src/commonMain/kotlin/TestCla.kt +++ /dev/null @@ -1,3 +0,0 @@ -class TestCla { - var plop: String = "" -} diff --git a/shared/src/commonMain/kotlin/TestClass.kt b/shared/src/commonMain/kotlin/TestClass.kt new file mode 100644 index 00000000..950d8db9 --- /dev/null +++ b/shared/src/commonMain/kotlin/TestClass.kt @@ -0,0 +1,5 @@ +class TestClass { + // TODO find a solution to remove this class + // It is necessary to build the iOS Framework + // Maybe by configuring src sets on iOS? +} diff --git a/shared/ui/build.gradle.kts b/shared/ui/build.gradle.kts index 47a8de86..d17c1893 100644 --- a/shared/ui/build.gradle.kts +++ b/shared/ui/build.gradle.kts @@ -29,7 +29,6 @@ kotlin { implementation(compose.ui) implementation(compose.components.resources) implementation(compose.components.uiToolingPreview) - api("at.asitplus:kmmresult:1.5.4") implementation(project(":shared:domain")) implementation(project(":shared:di")) api("io.github.qdsfdhvh:image-loader:1.7.8") diff --git a/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/common/LceViewModel.kt b/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/common/LceViewModel.kt index c67fa022..9c5c9b38 100644 --- a/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/common/LceViewModel.kt +++ b/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/common/LceViewModel.kt @@ -1,6 +1,5 @@ package com.androidmakers.ui.common -import at.asitplus.KmmResult import com.androidmakers.ui.model.Lce import kotlinx.coroutines.Job import kotlinx.coroutines.flow.Flow @@ -14,7 +13,7 @@ import moe.tlaster.precompose.viewmodel.viewModelScope abstract class LceViewModel : ViewModel() { - abstract fun produce(): Flow> + abstract fun produce(): Flow> private val _mutableSharedState = MutableStateFlow>(Lce.Loading) val values = _mutableSharedState.asStateFlow() diff --git a/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/model/Lce.kt b/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/model/Lce.kt index 652259f5..8019280b 100644 --- a/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/model/Lce.kt +++ b/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/model/Lce.kt @@ -1,6 +1,5 @@ package com.androidmakers.ui.model -import at.asitplus.KmmResult sealed interface Lce { object Loading : Lce @@ -8,7 +7,7 @@ sealed interface Lce { object Error : Lce } -fun KmmResult.toLce(): Lce = if (isSuccess) { +fun Result.toLce(): Lce = if (isSuccess) { Lce.Content(getOrThrow()) } else { Lce.Error diff --git a/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/sponsors/SponsorsViewModel.kt b/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/sponsors/SponsorsViewModel.kt index 52b6dcbe..7d7417de 100644 --- a/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/sponsors/SponsorsViewModel.kt +++ b/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/sponsors/SponsorsViewModel.kt @@ -1,6 +1,5 @@ package com.androidmakers.ui.sponsors -import at.asitplus.KmmResult import com.androidmakers.ui.common.LceViewModel import fr.androidmakers.domain.interactor.GetPartnersUseCase import fr.androidmakers.domain.model.PartnerGroup @@ -9,7 +8,7 @@ import kotlinx.coroutines.flow.Flow class SponsorsViewModel( private val getPartnersUseCase: GetPartnersUseCase ) : LceViewModel>() { - override fun produce(): Flow>> { + override fun produce(): Flow>> { return getPartnersUseCase() } diff --git a/shared/ui/src/iosMain/kotlin/com/androidmakers/ui/sponsors/SponsorViewController.kt b/shared/ui/src/iosMain/kotlin/com/androidmakers/ui/sponsors/SponsorViewController.kt index 2ff7275e..c370cb7b 100644 --- a/shared/ui/src/iosMain/kotlin/com/androidmakers/ui/sponsors/SponsorViewController.kt +++ b/shared/ui/src/iosMain/kotlin/com/androidmakers/ui/sponsors/SponsorViewController.kt @@ -1,10 +1,6 @@ package com.androidmakers.ui.sponsors -import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.getValue import androidx.compose.ui.window.ComposeUIViewController -import at.asitplus.KmmResult -import com.androidmakers.ui.model.Lce import com.androidmakers.ui.theme.AndroidMakersTheme import fr.androidmakers.di.DepContainer import platform.UIKit.UIViewController