mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
stub in syncSavedItemContent function in data service
This commit is contained in:
parent
26e0c78e19
commit
985d1ff7ae
2 changed files with 17 additions and 8 deletions
|
|
@ -1,9 +1,9 @@
|
|||
package app.omnivore.omnivore
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.room.Room
|
||||
import app.omnivore.omnivore.networking.Networker
|
||||
import app.omnivore.omnivore.networking.savedItem
|
||||
import app.omnivore.omnivore.networking.savedItemUpdates
|
||||
import app.omnivore.omnivore.persistence.AppDatabase
|
||||
import javax.inject.Inject
|
||||
|
|
@ -18,30 +18,38 @@ class DataService @Inject constructor(
|
|||
).build()
|
||||
}
|
||||
|
||||
suspend fun DataService.sync(since: String, cursor: String?, limit: Int = 15): SavedItemSyncMarker {
|
||||
val syncResult = networker.savedItemUpdates(cursor = cursor, limit = limit, since = since) ?: return SavedItemSyncMarker.errorResult
|
||||
suspend fun DataService.sync(since: String, cursor: String?, limit: Int = 15): SavedItemSyncResult {
|
||||
val syncResult = networker.savedItemUpdates(cursor = cursor, limit = limit, since = since) ?: return SavedItemSyncResult.errorResult
|
||||
|
||||
db.savedItemDao().insertAll(syncResult.items)
|
||||
|
||||
return SavedItemSyncMarker(
|
||||
return SavedItemSyncResult(
|
||||
hasError = false,
|
||||
hasMoreItems = syncResult.hasMoreItems,
|
||||
cursor = syncResult.cursor,
|
||||
count = syncResult.items.size
|
||||
count = syncResult.items.size,
|
||||
savedItemSlugs = syncResult.items.map { it.id }
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun DataService.syncSavedItemContent(slug: String) {
|
||||
val syncResult = networker.savedItem(slug)
|
||||
|
||||
// syncResult.item
|
||||
}
|
||||
|
||||
suspend fun DataService.syncOfflineItemsWithServerIfNeeded() {
|
||||
// TODO: implement this
|
||||
}
|
||||
|
||||
data class SavedItemSyncMarker(
|
||||
data class SavedItemSyncResult(
|
||||
val hasError: Boolean,
|
||||
val hasMoreItems: Boolean,
|
||||
val count: Int,
|
||||
val savedItemSlugs: List<String>,
|
||||
val cursor: String?
|
||||
) {
|
||||
companion object {
|
||||
val errorResult = SavedItemSyncMarker(hasError = true, hasMoreItems = true, cursor = null, count = 0)
|
||||
val errorResult = SavedItemSyncResult(hasError = true, hasMoreItems = true, cursor = null, count = 0, savedItemSlugs = listOf())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,7 +151,8 @@ suspend fun Networker.createHighlight(input: CreateHighlightInput): Highlight? {
|
|||
createdAt = null, // TODO: update gql query to get this
|
||||
updatedAt = null, // TODO: fix updatedAtString?.let { LocalDate.parse(it) },
|
||||
createdByMe = createdHighlight.highlightFields.createdByMe,
|
||||
markedForDeletion = false
|
||||
markedForDeletion = false,
|
||||
serverSyncStatus = 0
|
||||
)
|
||||
} else {
|
||||
return null
|
||||
|
|
|
|||
Loading…
Reference in a new issue