Fix delete propogation
This commit is contained in:
@ -51,29 +51,29 @@ suspend fun DataService.createWebHighlight(jsonString: String) {
|
||||
suspend fun DataService.createNoteHighlight(savedItemId: String, note: String) {
|
||||
val shortId = UUID.randomUUID().toString()
|
||||
val createHighlightId = UUID.randomUUID().toString()
|
||||
val createHighlightParams = CreateHighlightParams(
|
||||
type = HighlightType.NOTE,,
|
||||
shortId = shortId,
|
||||
id = createHighlightId,
|
||||
quote = null,
|
||||
patch = null,
|
||||
articleId = null,
|
||||
annotation = note,
|
||||
)
|
||||
// val createHighlightParams = CreateHighlightParams(
|
||||
// type = HighlightType.NOTE,,
|
||||
// shortId = shortId,
|
||||
// id = createHighlightId,
|
||||
// quote = null,
|
||||
// patch = null,
|
||||
// articleId = null,
|
||||
// annotation = note,
|
||||
// )
|
||||
|
||||
withContext(Dispatchers.IO) {
|
||||
val highlight = Highlight(
|
||||
type = "HIGHLIGHT",
|
||||
highlightId = createHighlightInput.id,
|
||||
shortId = createHighlightInput.shortId,
|
||||
quote = createHighlightInput.quote.getOrNull(),
|
||||
highlightId = createHighlightId,
|
||||
shortId = shortId,
|
||||
quote = null,
|
||||
prefix = null,
|
||||
suffix = null,
|
||||
patch = createHighlightInput.patch.getOrNull(),
|
||||
annotation = createHighlightInput.annotation.getOrNull(),
|
||||
patch =null,
|
||||
annotation = note,
|
||||
createdAt = null,
|
||||
updatedAt = null,
|
||||
createdByMe = false
|
||||
createdByMe = true
|
||||
)
|
||||
|
||||
highlight.serverSyncStatus = ServerSyncStatus.NEEDS_CREATION.rawValue
|
||||
@ -87,6 +87,7 @@ suspend fun DataService.createNoteHighlight(savedItemId: String, note: String) {
|
||||
db.savedItemAndHighlightCrossRefDao().insertAll(listOf(crossRef))
|
||||
|
||||
val newHighlight = networker.createHighlight(input = CreateHighlightParams(
|
||||
type = HighlightType.HIGHLIGHT,
|
||||
shortId = shortId,
|
||||
id = createHighlightId,
|
||||
quote = null,
|
||||
|
||||
@ -34,6 +34,10 @@ suspend fun DataService.sync(since: String, cursor: String?, limit: Int = 20): S
|
||||
val syncResult = networker.savedItemUpdates(cursor = cursor, limit = limit, since = since)
|
||||
?: return SavedItemSyncResult.errorResult
|
||||
|
||||
if (syncResult.deletedItemIDs.isNotEmpty()) {
|
||||
db.savedItemDao().deleteByIds(syncResult.deletedItemIDs)
|
||||
}
|
||||
|
||||
val savedItems = syncResult.items.map {
|
||||
val savedItem = SavedItem(
|
||||
savedItemId = it.id,
|
||||
|
||||
@ -23,8 +23,8 @@ data class CreateHighlightParams(
|
||||
val `annotation`: String?
|
||||
) {
|
||||
fun asCreateHighlightInput() = CreateHighlightInput(
|
||||
type = type,
|
||||
annotation = Optional.presentIfNotNull(`annotation`),
|
||||
type = Optional.presentIfNotNull(type),
|
||||
annotation = Optional.presentIfNotNull(annotation),
|
||||
articleId = articleId ?: "",
|
||||
id = id ?: "",
|
||||
patch = Optional.presentIfNotNull(patch),
|
||||
|
||||
@ -142,6 +142,9 @@ interface SavedItemDao {
|
||||
@Query("DELETE FROM savedItem WHERE savedItemId = :itemID")
|
||||
fun deleteById(itemID: String)
|
||||
|
||||
@Query("DELETE FROM savedItem WHERE savedItemId in (:itemIDs)")
|
||||
fun deleteByIds(itemIDs: List<String>)
|
||||
|
||||
@Update
|
||||
fun update(savedItem: SavedItem)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user