Set type on highlight objects so they are properly loaded

This commit is contained in:
Jackson Harper
2023-04-25 14:48:59 +08:00
parent 89c85e5627
commit a7d66fd4f2
8 changed files with 8 additions and 1 deletions

View File

@ -45,6 +45,7 @@ fragment ArticleFields on Article {
fragment HighlightFields on Highlight {
id
type
shortId
quote
prefix

View File

@ -13,6 +13,7 @@ suspend fun DataService.createWebHighlight(jsonString: String) {
withContext(Dispatchers.IO) {
val highlight = Highlight(
type = "HIGHLIGHT",
highlightId = createHighlightInput.id,
shortId = createHighlightInput.shortId,
quote = createHighlightInput.quote.getOrNull(),

View File

@ -113,6 +113,7 @@ suspend fun DataService.sync(since: String, cursor: String?, limit: Int = 20): S
it.highlights ?: listOf()
}.map {
Highlight(
type = it.highlightFields.type.toString(),
highlightId = it.highlightFields.id,
annotation = it.highlightFields.annotation,
createdByMe = it.highlightFields.createdByMe,

View File

@ -139,6 +139,7 @@ suspend fun Networker.createHighlight(input: CreateHighlightInput): Highlight? {
// val updatedAtString = createdHighlight.highlightFields.updatedAt as? String
return Highlight(
type = createdHighlight.highlightFields.type.toString(),
highlightId = createdHighlight.highlightFields.id,
shortId = createdHighlight.highlightFields.shortId,
quote = createdHighlight.highlightFields.quote,

View File

@ -44,6 +44,7 @@ suspend fun Networker.savedItem(slug: String): SavedItemQueryResponse {
Highlight(
highlightId = it.highlightFields.id,
type = it.highlightFields.type.toString(),
shortId = it.highlightFields.shortId,
quote = it.highlightFields.quote,
prefix = it.highlightFields.prefix,

View File

@ -71,6 +71,7 @@ suspend fun Networker.search(
highlights = (it.node.highlights ?: listOf()).map { highlight ->
Highlight(
highlightId = highlight.highlightFields.id,
type = highlight.highlightFields.type.toString(),
annotation = highlight.highlightFields.annotation,
createdByMe = highlight.highlightFields.createdByMe,
patch = highlight.highlightFields.patch,

View File

@ -13,7 +13,7 @@ import app.omnivore.omnivore.persistence.entities.*
SavedItemAndSavedItemLabelCrossRef::class,
SavedItemAndHighlightCrossRef::class
],
version = 5
version = 6
)
abstract class AppDatabase : RoomDatabase() {
abstract fun viewerDao(): ViewerDao

View File

@ -7,6 +7,7 @@ import app.omnivore.omnivore.models.ServerSyncStatus
@Entity
data class Highlight(
@PrimaryKey val highlightId: String,
val type: String,
var annotation: String?,
val createdAt: String?,
val createdByMe: Boolean,