-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd67966
commit 7537bb7
Showing
19 changed files
with
444 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
core/domain/src/commonMain/kotlin/club/nito/core/domain/FetchMyParticipantStatusUseCase.kt
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
core/domain/src/commonMain/kotlin/club/nito/core/domain/MyParticipantStatusStreamUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package club.nito.core.domain | ||
|
||
import club.nito.core.data.AuthRepository | ||
import club.nito.core.data.ParticipantRepository | ||
import club.nito.core.model.participant.ParticipantStatus | ||
import club.nito.core.model.schedule.ScheduleId | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
|
||
/** | ||
* 自身の参加状況を取得するユースケース | ||
*/ | ||
public sealed interface MyParticipantStatusStreamUseCase { | ||
public operator fun invoke(id: ScheduleId): Flow<ParticipantStatus> | ||
} | ||
|
||
public class FetchMyParticipantStatusExecutor( | ||
private val authRepository: AuthRepository, | ||
private val participantRepository: ParticipantRepository, | ||
) : MyParticipantStatusStreamUseCase { | ||
override fun invoke(id: ScheduleId): Flow<ParticipantStatus> = flow { | ||
val currentUserId = authRepository.currentUser().id | ||
participantRepository.participantStatusStream( | ||
scheduleId = id, | ||
userId = currentUserId, | ||
).collect { | ||
emit(it) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
core/domain/src/commonMain/kotlin/club/nito/core/domain/ScheduleParticipantsStreamUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package club.nito.core.domain | ||
|
||
import club.nito.core.data.ParticipantRepository | ||
import club.nito.core.model.FetchMultipleContentResult | ||
import club.nito.core.model.participant.ParticipantUser | ||
import club.nito.core.model.schedule.ScheduleId | ||
import club.nito.core.model.toNitoError | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.catch | ||
import kotlinx.coroutines.flow.map | ||
import kotlin.coroutines.cancellation.CancellationException | ||
|
||
/** | ||
* 該当スケジュールの参加者情報のストリームを取得するユースケース | ||
*/ | ||
public sealed interface ScheduleParticipantsStreamUseCase { | ||
public operator fun invoke(id: ScheduleId): Flow<FetchMultipleContentResult<ParticipantUser>> | ||
} | ||
|
||
public class ScheduleParticipantsStreamExecutor( | ||
private val participantRepository: ParticipantRepository, | ||
) : ScheduleParticipantsStreamUseCase { | ||
override fun invoke(id: ScheduleId): Flow<FetchMultipleContentResult<ParticipantUser>> { | ||
return participantRepository | ||
.participantUsersStream(scheduleId = id) | ||
.map { | ||
if (it.isEmpty()) { | ||
return@map FetchMultipleContentResult.NoContent | ||
} | ||
|
||
FetchMultipleContentResult.Success(it) | ||
} | ||
.catch { e -> | ||
if (e is CancellationException) { | ||
throw e | ||
} | ||
|
||
emit(FetchMultipleContentResult.Failure(e.toNitoError())) | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
core/domain/src/commonMain/kotlin/club/nito/core/domain/ScheduleStreamUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package club.nito.core.domain | ||
|
||
import club.nito.core.data.ScheduleRepository | ||
import club.nito.core.model.FetchSingleContentResult | ||
import club.nito.core.model.schedule.ScheduleId | ||
import club.nito.core.model.schedule.ScheduleWithPlace | ||
import club.nito.core.model.toNitoError | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.catch | ||
import kotlinx.coroutines.flow.map | ||
import kotlin.coroutines.cancellation.CancellationException | ||
|
||
/** | ||
* スケジュールを取得するユースケース | ||
*/ | ||
public sealed interface ScheduleStreamUseCase { | ||
public operator fun invoke(id: ScheduleId): Flow<FetchSingleContentResult<ScheduleWithPlace>> | ||
} | ||
|
||
public class ScheduleStreamExecutor( | ||
private val scheduleRepository: ScheduleRepository, | ||
) : ScheduleStreamUseCase { | ||
override fun invoke(id: ScheduleId): Flow<FetchSingleContentResult<ScheduleWithPlace>> { | ||
return scheduleRepository | ||
.scheduleWithPlaceStream(id = id) | ||
.map { | ||
it?.let { FetchSingleContentResult.Success(it) } | ||
?: FetchSingleContentResult.NoContent | ||
} | ||
.catch { e -> | ||
if (e is CancellationException) { | ||
throw e | ||
} | ||
|
||
emit(FetchSingleContentResult.Failure(e.toNitoError())) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.