docs: add state-management strategy reference and SQLDelight session log
Added documentation outlining the recommended frontend state-management approach using Unidirectional Data Flow (UDF). Documented the 2026-01-28 session addressing the critical SQLDelight async issue, detailing the analysis, fix implementation, and results. Updated PingEventRepositoryImpl to use `awaitAsOneOrNull` for proper async handling.
This commit is contained in:
+4
-6
@@ -3,6 +3,7 @@ package at.mocode.ping.feature.data
|
||||
import at.mocode.frontend.core.localdb.AppDatabase
|
||||
import at.mocode.frontend.core.sync.SyncableRepository
|
||||
import at.mocode.ping.api.PingEvent
|
||||
import app.cash.sqldelight.async.coroutines.awaitAsOneOrNull
|
||||
|
||||
// ARCH-BLUEPRINT: This repository implements the generic SyncableRepository
|
||||
// for a specific entity, bridging the gap between the sync core and the local database.
|
||||
@@ -12,12 +13,9 @@ class PingEventRepositoryImpl(
|
||||
|
||||
// The `since` parameter for our sync is the ID of the last event, not a timestamp.
|
||||
override suspend fun getLatestSince(): String? {
|
||||
println("PingEventRepositoryImpl: getLatestSince called")
|
||||
// WORKAROUND: executeAsOneOrNull() fails with "driver is asynchronous" error.
|
||||
// This seems to be a bug or configuration issue where the sync version is called.
|
||||
// Since we are in Phase 2 (Tracer Bullet), we can live with a full sync for now.
|
||||
// We return null to force a full sync, which works because upsert() works.
|
||||
return null
|
||||
println("PingEventRepositoryImpl: getLatestSince called - using corrected async implementation")
|
||||
// FIX: Use .awaitAsOneOrNull() for async drivers instead of the blocking .executeAsOneOrNull()
|
||||
return db.appDatabaseQueries.selectLatestPingEventId().awaitAsOneOrNull()
|
||||
}
|
||||
|
||||
override suspend fun upsert(items: List<PingEvent>) {
|
||||
|
||||
Reference in New Issue
Block a user