add network call to fetch article content when opening web view

This commit is contained in:
Satindar Dhillon
2022-09-20 11:12:07 -07:00
parent 57b4e47ac0
commit 08aef33514
6 changed files with 156 additions and 60 deletions

View File

@ -0,0 +1,64 @@
query GetArticle($slug: String!) {
article(username: "me", slug: $slug) {
... on ArticleSuccess {
article {
...ArticleFields
content
highlights(input: { includeFriends: false }) {
...HighlightFields
}
labels {
...LabelFields
}
}
}
... on ArticleError {
errorCodes
}
}
}
fragment ArticleFields on Article {
id
title
url
author
image
savedAt
createdAt
publishedAt
contentReader
originalArticleUrl
readingProgressPercent
readingProgressAnchorIndex
slug
isArchived
description
linkId
siteName
state
readAt
updatedAt
content
}
fragment HighlightFields on Highlight {
id
shortId
quote
prefix
suffix
patch
annotation
createdByMe
updatedAt
sharedAt
}
fragment LabelFields on Label {
id
name
color
description
createdAt
}

View File

@ -34,6 +34,8 @@ query Search($after: String, $first: Int, $query: String) {
siteName
subscription
readAt
savedAt
updatedAt
}
}
pageInfo {

View File

@ -2,28 +2,26 @@ package app.omnivore.omnivore.models
import androidx.core.net.toUri
public data class LinkedItem(
public val id: String,
public val title: String,
public val createdAt: Any,
// public val savedAt: Any,
public val readAt: Any?,
// public val updatedAt: Any,
public val readingProgress: Double,
public val readingProgressAnchor: Int,
public val imageURLString: String?,
// public val onDeviceImageURLString: String?,
// public val documentDirectoryPath: String?,
public val pageURLString: String,
public val descriptionText: String?,
public val publisherURLString: String?,
// public val siteName: String?,
public val author: String?,
public val publishDate: Any?,
public val slug: String,
// public val isArchived: Boolean,
// public val contentReader: String?,
// public val originalHtml: String?,
data class LinkedItem(
val id: String,
val title: String,
val createdAt: Any,
val savedAt: Any,
val readAt: Any?,
val updatedAt: Any?,
val readingProgress: Double,
val readingProgressAnchor: Int,
val imageURLString: String?,
val pageURLString: String,
val descriptionText: String?,
val publisherURLString: String?,
val siteName: String?,
val author: String?,
val publishDate: Any?,
val slug: String,
val isArchived: Boolean,
val contentReader: String?,
val content: String?
) {
fun publisherDisplayName(): String? {
return publisherURLString?.toUri()?.host

View File

@ -1,6 +1,5 @@
package app.omnivore.omnivore.ui.home
import androidx.core.net.toUri
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
@ -89,16 +88,22 @@ class HomeViewModel @Inject constructor(
id = it.node.id,
title = it.node.title,
createdAt = it.node.createdAt,
savedAt = it.node.savedAt,
readAt = it.node.readAt,
updatedAt = it.node.updatedAt,
readingProgress = it.node.readingProgressPercent,
readingProgressAnchor = it.node.readingProgressAnchorIndex,
imageURLString = it.node.image,
pageURLString = it.node.url,
descriptionText = it.node.description,
publisherURLString = it.node.originalArticleUrl,
siteName = it.node.siteName,
author = it.node.author,
publishDate = it.node.publishedAt,
slug = it.node.slug,
publishDate = it.node.publishedAt
isArchived = it.node.isArchived,
contentReader = it.node.contentReader.rawValue,
content = null
)
}

View File

@ -15,7 +15,7 @@ fun WebReaderLoadingContainer(slug: String, webReaderViewModel: WebReaderViewMod
val webReaderParams: WebReaderParams? by webReaderViewModel.webReaderParamsLiveData.observeAsState(null)
if (webReaderParams == null) {
webReaderViewModel.loadItem()
webReaderViewModel.loadItem(slug = slug)
}
if (webReaderParams != null) {

File diff suppressed because one or more lines are too long