rename id fields to reflect entity type
This commit is contained in:
@ -28,7 +28,7 @@ suspend fun DataService.sync(since: String, cursor: String?, limit: Int = 15): S
|
||||
hasMoreItems = syncResult.hasMoreItems,
|
||||
cursor = syncResult.cursor,
|
||||
count = syncResult.items.size,
|
||||
savedItemSlugs = syncResult.items.map { it.id }
|
||||
savedItemSlugs = syncResult.items.map { it.savedItemId }
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -8,11 +8,9 @@ import app.omnivore.omnivore.graphql.generated.UpdateHighlightMutation
|
||||
import app.omnivore.omnivore.graphql.generated.type.CreateHighlightInput
|
||||
import app.omnivore.omnivore.graphql.generated.type.MergeHighlightInput
|
||||
import app.omnivore.omnivore.graphql.generated.type.UpdateHighlightInput
|
||||
import app.omnivore.omnivore.models.ServerSyncStatus
|
||||
import app.omnivore.omnivore.persistence.entities.Highlight
|
||||
import com.apollographql.apollo3.api.Optional
|
||||
import com.google.gson.Gson
|
||||
import java.time.LocalDate
|
||||
|
||||
data class CreateHighlightParams(
|
||||
val shortId: String?,
|
||||
@ -141,7 +139,7 @@ suspend fun Networker.createHighlight(input: CreateHighlightInput): Highlight? {
|
||||
// val updatedAtString = createdHighlight.highlightFields.updatedAt as? String
|
||||
|
||||
return Highlight(
|
||||
id = createdHighlight.highlightFields.id,
|
||||
highlightId = createdHighlight.highlightFields.id,
|
||||
shortId = createdHighlight.highlightFields.shortId,
|
||||
quote = createdHighlight.highlightFields.quote,
|
||||
prefix = createdHighlight.highlightFields.prefix,
|
||||
|
||||
@ -30,7 +30,7 @@ suspend fun Networker.savedItem(slug: String): SavedItemQueryResponse {
|
||||
|
||||
val savedItemLabels = labels.map {
|
||||
SavedItemLabel(
|
||||
id = it.labelFields.id,
|
||||
savedItemLabelId = it.labelFields.id,
|
||||
name = it.labelFields.name,
|
||||
color = it.labelFields.color,
|
||||
createdAt = it.labelFields.createdAt as String?,
|
||||
@ -42,7 +42,7 @@ suspend fun Networker.savedItem(slug: String): SavedItemQueryResponse {
|
||||
// val updatedAtString = it.highlightFields.updatedAt as? String
|
||||
|
||||
Highlight(
|
||||
id = it.highlightFields.id,
|
||||
highlightId = it.highlightFields.id,
|
||||
shortId = it.highlightFields.shortId,
|
||||
quote = it.highlightFields.quote,
|
||||
prefix = it.highlightFields.prefix,
|
||||
@ -60,7 +60,7 @@ suspend fun Networker.savedItem(slug: String): SavedItemQueryResponse {
|
||||
// TODO: handle errors
|
||||
|
||||
val savedItem = SavedItem(
|
||||
id = article.articleFields.id,
|
||||
savedItemId = article.articleFields.id,
|
||||
title = article.articleFields.title,
|
||||
createdAt = article.articleFields.createdAt as String,
|
||||
savedAt = article.articleFields.savedAt as String,
|
||||
|
||||
@ -41,7 +41,7 @@ suspend fun Networker.savedItemUpdates(
|
||||
|
||||
val savedItems = itemNodes.map {
|
||||
SavedItem(
|
||||
id = it.id,
|
||||
savedItemId = it.id,
|
||||
title = it.title,
|
||||
createdAt = it.createdAt as String,
|
||||
savedAt = it.savedAt as String,
|
||||
|
||||
@ -22,7 +22,7 @@ suspend fun Networker.typeaheadSearch(
|
||||
|
||||
val cardsData = itemList.map {
|
||||
SavedItemCardData(
|
||||
id = it.id,
|
||||
savedItemId = it.id,
|
||||
slug = it.slug,
|
||||
publisherURLString = "",
|
||||
title = it.title,
|
||||
@ -59,7 +59,7 @@ suspend fun Networker.search(
|
||||
|
||||
val cardsData = itemList.map {
|
||||
SavedItemCardData(
|
||||
id = it.node.id,
|
||||
savedItemId = it.node.id,
|
||||
slug = it.node.slug,
|
||||
publisherURLString = it.node.originalArticleUrl,
|
||||
title = it.node.title,
|
||||
|
||||
@ -2,13 +2,12 @@ package app.omnivore.omnivore.persistence.entities
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import app.omnivore.omnivore.models.ServerSyncStatus
|
||||
import java.time.LocalDate
|
||||
import java.util.Date
|
||||
|
||||
@Entity
|
||||
data class Highlight(
|
||||
@PrimaryKey val id: String,
|
||||
@PrimaryKey val highlightId: String,
|
||||
val annotation: String?,
|
||||
val createdAt: Date?,
|
||||
val createdByMe: Boolean,
|
||||
|
||||
@ -5,8 +5,7 @@ import androidx.room.PrimaryKey
|
||||
|
||||
@Entity
|
||||
data class NewsletterEmail(
|
||||
@PrimaryKey val userID: String,
|
||||
@PrimaryKey val newsletterEmailId: String?,
|
||||
val confirmationCode: String?,
|
||||
val email: String?,
|
||||
val emailID: String?
|
||||
val email: String?
|
||||
)
|
||||
|
||||
@ -5,7 +5,7 @@ import androidx.room.PrimaryKey
|
||||
|
||||
@Entity
|
||||
data class RecentSearchItem(
|
||||
@PrimaryKey val id: String,
|
||||
@PrimaryKey val recentSearchItemId: String,
|
||||
val savedAt: String?,
|
||||
val term: String?
|
||||
)
|
||||
|
||||
@ -5,7 +5,7 @@ import androidx.room.PrimaryKey
|
||||
|
||||
@Entity
|
||||
data class RecommendationGroup(
|
||||
@PrimaryKey val id: String,
|
||||
@PrimaryKey val recommendationGroupId: String,
|
||||
val name: String?,
|
||||
val canPost: Boolean,
|
||||
val canSeeMembers: Boolean,
|
||||
|
||||
@ -7,7 +7,7 @@ import java.util.*
|
||||
|
||||
@Entity
|
||||
data class SavedItem(
|
||||
@PrimaryKey val id: String,
|
||||
@PrimaryKey val savedItemId: String,
|
||||
val title: String,
|
||||
val createdAt: String,
|
||||
val savedAt: String,
|
||||
@ -47,43 +47,24 @@ data class SavedItem(
|
||||
return publisherURLString?.toUri()?.host
|
||||
}
|
||||
|
||||
fun isPDF(): Boolean {
|
||||
val hasPDFSuffix = pageURLString.endsWith("pdf")
|
||||
return contentReader == "PDF" || hasPDFSuffix
|
||||
}
|
||||
|
||||
fun asSavedItemCardData(): SavedItemCardData {
|
||||
return SavedItemCardData(
|
||||
id = id,
|
||||
slug = slug,
|
||||
publisherURLString = publisherURLString,
|
||||
title = title,
|
||||
author = author,
|
||||
imageURLString = imageURLString,
|
||||
isArchived = isArchived,
|
||||
pageURLString = pageURLString,
|
||||
contentReader = contentReader,
|
||||
)
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as SavedItem
|
||||
|
||||
if (id != other.id) return false
|
||||
if (savedItemId != other.savedItemId) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return id.hashCode()
|
||||
return savedItemId.hashCode()
|
||||
}
|
||||
}
|
||||
|
||||
data class SavedItemCardData(
|
||||
val id: String,
|
||||
val savedItemId: String,
|
||||
val slug: String,
|
||||
val publisherURLString: String?,
|
||||
val title: String,
|
||||
@ -105,7 +86,7 @@ data class SavedItemCardData(
|
||||
|
||||
@Dao
|
||||
interface SavedItemDao {
|
||||
@Query("SELECT id, slug, publisherURLString, title, author, imageURLString, isArchived, pageURLString, contentReader FROM SavedItem ORDER BY savedAt DESC")
|
||||
@Query("SELECT savedItemId, slug, publisherURLString, title, author, imageURLString, isArchived, pageURLString, contentReader FROM SavedItem ORDER BY savedAt DESC")
|
||||
fun getLibraryLiveData(): LiveData<List<SavedItemCardData>>
|
||||
|
||||
@Query("SELECT * FROM savedItem")
|
||||
@ -114,6 +95,6 @@ interface SavedItemDao {
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insertAll(items: List<SavedItem>)
|
||||
|
||||
@Query("DELETE FROM savedItem WHERE id = :itemID")
|
||||
@Query("DELETE FROM savedItem WHERE savedItemId = :itemID")
|
||||
fun deleteById(itemID: String)
|
||||
}
|
||||
|
||||
@ -2,11 +2,10 @@ package app.omnivore.omnivore.persistence.entities
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import app.omnivore.omnivore.models.ServerSyncStatus
|
||||
|
||||
@Entity
|
||||
data class SavedItemLabel(
|
||||
@PrimaryKey val id: String,
|
||||
@PrimaryKey val savedItemLabelId: String,
|
||||
val name: String,
|
||||
val color: String,
|
||||
val createdAt: String?,
|
||||
|
||||
@ -20,7 +20,6 @@ import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.navigation.NavHostController
|
||||
import app.omnivore.omnivore.Routes
|
||||
import app.omnivore.omnivore.persistence.entities.SavedItem
|
||||
import app.omnivore.omnivore.persistence.entities.SavedItemCardData
|
||||
import app.omnivore.omnivore.ui.savedItemViews.SavedItemCard
|
||||
import app.omnivore.omnivore.ui.reader.PDFReaderActivity
|
||||
@ -101,7 +100,7 @@ fun LibraryViewContent(
|
||||
navController.navigate("WebReader/${cardData.slug}")
|
||||
}
|
||||
},
|
||||
actionHandler = { libraryViewModel.handleSavedItemAction(cardData.id, it) }
|
||||
actionHandler = { libraryViewModel.handleSavedItemAction(cardData.savedItemId, it) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ class PDFReaderViewModel @Inject constructor(
|
||||
currentReadingProgress = percent
|
||||
viewModelScope.launch {
|
||||
val params = ReadingProgressParams(
|
||||
id = pdfReaderParamsLiveData.value?.item?.id,
|
||||
id = pdfReaderParamsLiveData.value?.item?.savedItemId,
|
||||
readingProgressPercent = percent,
|
||||
readingProgressAnchorIndex = currentPageIndex
|
||||
)
|
||||
@ -102,7 +102,7 @@ class PDFReaderViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun syncHighlightUpdates(newAnnotation: Annotation, quote: String, overlapIds: List<String>, note: String? = null) {
|
||||
val itemID = pdfReaderParamsLiveData.value?.item?.id ?: return
|
||||
val itemID = pdfReaderParamsLiveData.value?.item?.savedItemId ?: return
|
||||
val highlightID = UUID.randomUUID().toString()
|
||||
val shortID = UUID.randomUUID().toString().replace("-","").substring(0,8)
|
||||
|
||||
|
||||
@ -113,7 +113,7 @@ fun WebReaderLoadingContainer(slug: String, webReaderViewModel: WebReaderViewMod
|
||||
isExpanded = isMenuExpanded,
|
||||
isArchived = webReaderParams!!.item.isArchived,
|
||||
onDismiss = { isMenuExpanded = false },
|
||||
actionHandler = { webReaderViewModel.handleSavedItemAction(webReaderParams!!.item.id, it) }
|
||||
actionHandler = { webReaderViewModel.handleSavedItemAction(webReaderParams!!.item.savedItemId, it) }
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@ -77,8 +77,8 @@ data class WebReaderContent(
|
||||
}
|
||||
|
||||
window.omnivoreArticle = {
|
||||
id: "${item.id}",
|
||||
linkId: "${item.id}",
|
||||
id: "${item.savedItemId}",
|
||||
linkId: "${item.savedItemId}",
|
||||
slug: "${item.slug}",
|
||||
createdAt: new Date(1662571290735.0).toISOString(),
|
||||
savedAt: new Date(1662571290981.0).toISOString(),
|
||||
|
||||
Reference in New Issue
Block a user