Files
smoa/app/src/main/java/com/smoa/sync/SyncConflictSnapshotRepository.kt
T
defiQUG a2dc194a49 Monorepo: Gitea CI, docs, auth/sync, backend APIs, gitignore
- Add Gitea Actions workflow; point README to gitea.d-bis.org/Sankofa_Phoenix/SMOA
- Expand .gitignore for Spring H2 data, secrets, Kotlin .kotlin/, tooling
- Track docs/api/generated ReDoc bundle; refresh api docs README
- Android: network/auth/sync, UI shell, tests; backend credentials/integrity APIs
- Docs, scripts (generate-api-docs), modules and core updates

Made-with: Cursor
2026-03-23 20:19:24 -07:00

40 lines
1.2 KiB
Kotlin

package com.smoa.sync
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.withContext
import javax.inject.Inject
import javax.inject.Singleton
/**
* Read and manage persisted sync conflict snapshots (order, evidence, directory, report).
* Compose UI can collect [observeSnapshots] or [observeByResourceType] for settings / debug / recovery flows.
*/
@Singleton
class SyncConflictSnapshotRepository @Inject constructor(
private val dao: SyncConflictSnapshotDao
) {
fun observeSnapshots(): Flow<List<SyncConflictSnapshotEntity>> = dao.observeAll()
fun observeByResourceType(resourceType: String): Flow<List<SyncConflictSnapshotEntity>> =
dao.observeByResourceType(resourceType)
suspend fun getSnapshot(resourceType: String, itemId: String): SyncConflictSnapshotEntity? =
withContext(Dispatchers.IO) {
dao.get(resourceType, itemId)
}
suspend fun deleteSnapshot(resourceType: String, itemId: String) {
withContext(Dispatchers.IO) {
dao.delete(resourceType, itemId)
}
}
suspend fun clearAll() {
withContext(Dispatchers.IO) {
dao.clearAll()
}
}
}