-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(schedule): use flow to fetch schedule details.
- Loading branch information
1 parent
7e710f0
commit f3ba7b6
Showing
6 changed files
with
66 additions
and
33 deletions.
There are no files selected for viewing
Binary file modified
BIN
-5.2 KB
(99%)
...codeproj/project.xcworkspace/xcuserdata/GERARD.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
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
32 changes: 22 additions & 10 deletions
32
shared/core/src/commonMain/kotlin/org/gdglille/devfest/database/TalkDao.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 |
---|---|---|
@@ -1,23 +1,35 @@ | ||
package org.gdglille.devfest.database | ||
|
||
import app.cash.sqldelight.coroutines.asFlow | ||
import app.cash.sqldelight.coroutines.mapToList | ||
import app.cash.sqldelight.coroutines.mapToOne | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.IO | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.combine | ||
import org.gdglille.devfest.Platform | ||
import org.gdglille.devfest.database.mappers.convertTalkUi | ||
import org.gdglille.devfest.db.Conferences4HallDatabase | ||
import org.gdglille.devfest.models.ui.TalkUi | ||
|
||
class TalkDao(private val db: Conferences4HallDatabase, private val platform: Platform) { | ||
fun fetchTalk(eventId: String, talkId: String): TalkUi = db.transactionWithResult { | ||
val talk = db.sessionQueries | ||
.selectSessionByTalkId(eventId, talkId) | ||
.executeAsOne() | ||
talk.convertTalkUi( | ||
platform::getString, | ||
db.sessionQueries | ||
fun fetchTalk(eventId: String, talkId: String): Flow<TalkUi> = db.transactionWithResult { | ||
combine( | ||
flow = db.sessionQueries | ||
.selectSpeakersByTalkId(event_id = eventId, talk_id = talkId) | ||
.executeAsList(), | ||
db.eventQueries | ||
.asFlow() | ||
.mapToList(Dispatchers.IO), | ||
flow2 = db.eventQueries | ||
.selectOpenfeedbackProjectId(eventId) | ||
.executeAsOne() | ||
.asFlow() | ||
.mapToOne(Dispatchers.IO), | ||
flow3 = db.sessionQueries | ||
.selectSessionByTalkId(eventId, talkId) | ||
.asFlow() | ||
.mapToOne(Dispatchers.IO), | ||
transform = { speakers, openfeedback, talk -> | ||
talk.convertTalkUi(platform::getString, speakers, openfeedback) | ||
} | ||
) | ||
} | ||
} |
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