This commit is contained in:
Stefano Sansone
2024-04-24 22:39:50 +02:00
parent 83d8fa9351
commit accbc57c00
26 changed files with 1724 additions and 1734 deletions

View File

@ -1,12 +1,12 @@
mutation SetLabels($input: SetLabelsInput!) {
setLabels(input: $input) {
... on SetLabelsSuccess {
labels {
...LabelFields
}
setLabels(input: $input) {
... on SetLabelsSuccess {
labels {
...LabelFields
}
}
... on SetLabelsError {
errorCodes
}
}
... on SetLabelsError {
errorCodes
}
}
}

View File

@ -1,12 +1,12 @@
mutation SetLinkArchived($input: ArchiveLinkInput!) {
setLinkArchived(input: $input) {
... on ArchiveLinkSuccess {
linkId
message
setLinkArchived(input: $input) {
... on ArchiveLinkSuccess {
linkId
message
}
... on ArchiveLinkError {
message
errorCodes
}
}
... on ArchiveLinkError {
message
errorCodes
}
}
}

View File

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

View File

@ -1,13 +1,13 @@
mutation CreateHighlight($input: CreateHighlightInput!) {
createHighlight(input: $input) {
... on CreateHighlightSuccess {
highlight {
...HighlightFields
}
}
createHighlight(input: $input) {
... on CreateHighlightSuccess {
highlight {
...HighlightFields
}
}
... on CreateHighlightError {
errorCodes
... on CreateHighlightError {
errorCodes
}
}
}
}

View File

@ -1,16 +1,16 @@
mutation CreateLabel($input: CreateLabelInput!) {
createLabel(input: $input) {
... on CreateLabelSuccess {
label {
id
name
color
description
createdAt
}
createLabel(input: $input) {
... on CreateLabelSuccess {
label {
id
name
color
description
createdAt
}
}
... on CreateLabelError {
errorCodes
}
}
... on CreateLabelError {
errorCodes
}
}
}

View File

@ -1,12 +1,12 @@
mutation DeleteHighlight($highlightId: ID!) {
deleteHighlight(highlightId: $highlightId) {
... on DeleteHighlightSuccess {
highlight {
id
}
deleteHighlight(highlightId: $highlightId) {
... on DeleteHighlightSuccess {
highlight {
id
}
}
... on DeleteHighlightError {
errorCodes
}
}
... on DeleteHighlightError {
errorCodes
}
}
}

View File

@ -1,12 +1,12 @@
mutation SetBookmarkArticle($input: SetBookmarkArticleInput!) {
setBookmarkArticle(input: $input) {
... on SetBookmarkArticleSuccess {
bookmarkedArticle {
id
}
setBookmarkArticle(input: $input) {
... on SetBookmarkArticleSuccess {
bookmarkedArticle {
id
}
}
... on SetBookmarkArticleError {
errorCodes
}
}
... on SetBookmarkArticleError {
errorCodes
}
}
}

View File

@ -1,12 +1,12 @@
query GetLabels {
labels {
... on LabelsSuccess {
labels {
...LabelFields
}
labels {
... on LabelsSuccess {
labels {
...LabelFields
}
}
... on LabelsError {
errorCodes
}
}
... on LabelsError {
errorCodes
}
}
}

View File

@ -1,23 +1,23 @@
mutation MergeHighlight($input: MergeHighlightInput!) {
mergeHighlight(input: $input) {
... on MergeHighlightSuccess {
highlight {
id
shortId
quote
prefix
suffix
patch
createdAt
updatedAt
annotation
sharedAt
createdByMe
}
overlapHighlightIdList
mergeHighlight(input: $input) {
... on MergeHighlightSuccess {
highlight {
id
shortId
quote
prefix
suffix
patch
createdAt
updatedAt
annotation
sharedAt
createdByMe
}
overlapHighlightIdList
}
... on MergeHighlightError {
errorCodes
}
}
... on MergeHighlightError {
errorCodes
}
}
}

View File

@ -1,14 +1,14 @@
mutation SaveArticleReadingProgress($input: SaveArticleReadingProgressInput!) {
saveArticleReadingProgress(input: $input) {
... on SaveArticleReadingProgressSuccess {
updatedArticle {
id
readingProgressPercent
readingProgressAnchorIndex
}
saveArticleReadingProgress(input: $input) {
... on SaveArticleReadingProgressSuccess {
updatedArticle {
id
readingProgressPercent
readingProgressAnchorIndex
}
}
... on SaveArticleReadingProgressError {
errorCodes
}
}
... on SaveArticleReadingProgressError {
errorCodes
}
}
}

View File

@ -1,10 +1,10 @@
mutation SaveUrl($input: SaveUrlInput!) {
saveUrl(input: $input) {
... on SaveSuccess {
url
saveUrl(input: $input) {
... on SaveSuccess {
url
}
... on SaveError {
errorCodes
}
}
... on SaveError {
errorCodes
}
}
}

View File

@ -1,55 +1,55 @@
query Search($after: String, $first: Int, $query: String) {
search(first: $first, after: $after, query: $query) {
... on SearchSuccess {
edges {
cursor
node {
id
title
slug
url
pageType
contentReader
createdAt
isArchived
readingProgressPercent
readingProgressAnchorIndex
author
image
description
publishedAt
ownedByViewer
originalArticleUrl
uploadFileId
labels {
...LabelFields
}
highlights {
...HighlightFields
}
pageId
shortId
quote
annotation
state
siteName
subscription
readAt
savedAt
updatedAt
wordsCount
search(first: $first, after: $after, query: $query) {
... on SearchSuccess {
edges {
cursor
node {
id
title
slug
url
pageType
contentReader
createdAt
isArchived
readingProgressPercent
readingProgressAnchorIndex
author
image
description
publishedAt
ownedByViewer
originalArticleUrl
uploadFileId
labels {
...LabelFields
}
highlights {
...HighlightFields
}
pageId
shortId
quote
annotation
state
siteName
subscription
readAt
savedAt
updatedAt
wordsCount
}
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
totalCount
}
}
... on SearchError {
errorCodes
}
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
totalCount
}
}
... on SearchError {
errorCodes
}
}
}

View File

@ -1,15 +1,15 @@
query TypeaheadSearch($query: String!) {
typeaheadSearch(query: $query) {
... on TypeaheadSearchSuccess {
items {
id
title
slug
siteName
}
typeaheadSearch(query: $query) {
... on TypeaheadSearchSuccess {
items {
id
title
slug
siteName
}
}
... on TypeaheadSearchError {
errorCodes
}
}
... on TypeaheadSearchError {
errorCodes
}
}
}

View File

@ -1,13 +1,13 @@
mutation UpdateHighlight($input: UpdateHighlightInput!) {
updateHighlight(input: $input) {
... on UpdateHighlightSuccess {
highlight {
id
}
}
updateHighlight(input: $input) {
... on UpdateHighlightSuccess {
highlight {
id
}
}
... on UpdateHighlightError {
errorCodes
... on UpdateHighlightError {
errorCodes
}
}
}
}

View File

@ -1,15 +1,15 @@
mutation UpdatePage($input: UpdatePageInput!) {
updatePage(input: $input) {
... on UpdatePageSuccess {
updatedPage {
title
author
description
}
}
updatePage(input: $input) {
... on UpdatePageSuccess {
updatedPage {
title
author
description
}
}
... on UpdatePageError {
errorCodes
... on UpdatePageError {
errorCodes
}
}
}
}

View File

@ -1,63 +1,63 @@
query UpdatesSince(
$folder: String
$after: String
$first: Int
$since: Date!
$folder: String
$after: String
$first: Int
$since: Date!
) {
updatesSince(after: $after, first: $first, folder: $folder, since: $since) {
... on UpdatesSinceSuccess {
edges {
cursor
itemID
updateReason
node {
id
title
slug
url
pageType
contentReader
createdAt
isArchived
readingProgressPercent
readingProgressAnchorIndex
author
image
description
publishedAt
ownedByViewer
originalArticleUrl
uploadFileId
labels {
...LabelFields
}
highlights {
...HighlightFields
}
pageId
shortId
quote
annotation
state
siteName
subscription
readAt
savedAt
updatedAt
language
wordsCount
updatesSince(after: $after, first: $first, folder: $folder, since: $since) {
... on UpdatesSinceSuccess {
edges {
cursor
itemID
updateReason
node {
id
title
slug
url
pageType
contentReader
createdAt
isArchived
readingProgressPercent
readingProgressAnchorIndex
author
image
description
publishedAt
ownedByViewer
originalArticleUrl
uploadFileId
labels {
...LabelFields
}
highlights {
...HighlightFields
}
pageId
shortId
quote
annotation
state
siteName
subscription
readAt
savedAt
updatedAt
language
wordsCount
}
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
totalCount
}
}
... on UpdatesSinceError {
errorCodes
}
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
totalCount
}
}
... on UpdatesSinceError {
errorCodes
}
}
}

View File

@ -1,3 +1,3 @@
query ValidateUsername($username: String!) {
validateUsername(username: $username)
validateUsername(username: $username)
}

View File

@ -1,14 +1,14 @@
query Viewer {
me {
id
name
isFullUser
intercomHash
profile {
id
username
pictureUrl
bio
me {
id
name
isFullUser
intercomHash
profile {
id
username
pictureUrl
bio
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,100 +1,90 @@
package app.omnivore.omnivore.core.network
import app.omnivore.omnivore.core.data.model.ServerSyncStatus
import app.omnivore.omnivore.core.database.entities.Highlight
import app.omnivore.omnivore.core.database.entities.SavedItem
import app.omnivore.omnivore.core.database.entities.SavedItemLabel
import app.omnivore.omnivore.graphql.generated.SearchQuery
import app.omnivore.omnivore.core.data.model.ServerSyncStatus
import com.apollographql.apollo3.api.Optional
data class LibrarySearchQueryResponse(
val cursor: String?,
val items: List<LibrarySearchItem>
val cursor: String?, val items: List<LibrarySearchItem>
)
data class LibrarySearchItem(
val item: SavedItem,
val labels: List<SavedItemLabel>,
val highlights: List<Highlight>
val item: SavedItem, val labels: List<SavedItemLabel>, val highlights: List<Highlight>
)
suspend fun Networker.search(
cursor: String? = null,
limit: Int = 15,
query: String
cursor: String? = null, limit: Int = 15, query: String
): LibrarySearchQueryResponse {
try {
val result = authenticatedApolloClient().query(
SearchQuery(
after = Optional.presentIfNotNull(cursor),
first = Optional.presentIfNotNull(limit),
query = Optional.presentIfNotNull(query)
)
).execute()
try {
val result = authenticatedApolloClient().query(
SearchQuery(
after = Optional.presentIfNotNull(cursor),
first = Optional.presentIfNotNull(limit),
query = Optional.presentIfNotNull(query)
)
).execute()
val newCursor = result.data?.search?.onSearchSuccess?.pageInfo?.endCursor
val itemList = result.data?.search?.onSearchSuccess?.edges ?: listOf()
val newCursor = result.data?.search?.onSearchSuccess?.pageInfo?.endCursor
val itemList = result.data?.search?.onSearchSuccess?.edges ?: listOf()
val searchItems = itemList.map {
LibrarySearchItem(
item = SavedItem(
savedItemId = it.node.id,
title = it.node.title,
createdAt = it.node.createdAt as String,
savedAt = it.node.savedAt as String,
readAt = it.node.readAt as String?,
updatedAt = it.node.updatedAt as String?,
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 as String?,
slug = it.node.slug,
isArchived = it.node.isArchived,
contentReader = it.node.contentReader.rawValue,
content = null,
wordsCount = it.node.wordsCount,
),
labels = (it.node.labels ?: listOf()).map { label ->
SavedItemLabel(
savedItemLabelId = label.labelFields.id,
name = label.labelFields.name,
color = label.labelFields.color,
createdAt = label.labelFields.createdAt as String?,
labelDescription = null
)
},
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,
prefix = highlight.highlightFields.prefix,
quote = highlight.highlightFields.quote,
serverSyncStatus = ServerSyncStatus.IS_SYNCED.rawValue,
shortId = highlight.highlightFields.shortId,
suffix = highlight.highlightFields.suffix,
updatedAt = highlight.highlightFields.updatedAt as String?,
createdAt = highlight.highlightFields.createdAt as String?,
color = highlight.highlightFields.color,
highlightPositionPercent = highlight.highlightFields.highlightPositionPercent,
highlightPositionAnchorIndex = highlight.highlightFields.highlightPositionAnchorIndex
)
val searchItems = itemList.map {
LibrarySearchItem(item = SavedItem(
savedItemId = it.node.id,
title = it.node.title,
createdAt = it.node.createdAt as String,
savedAt = it.node.savedAt as String,
readAt = it.node.readAt as String?,
updatedAt = it.node.updatedAt as String?,
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 as String?,
slug = it.node.slug,
isArchived = it.node.isArchived,
contentReader = it.node.contentReader.rawValue,
content = null,
wordsCount = it.node.wordsCount,
), labels = (it.node.labels ?: listOf()).map { label ->
SavedItemLabel(
savedItemLabelId = label.labelFields.id,
name = label.labelFields.name,
color = label.labelFields.color,
createdAt = label.labelFields.createdAt as String?,
labelDescription = null
)
}, 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,
prefix = highlight.highlightFields.prefix,
quote = highlight.highlightFields.quote,
serverSyncStatus = ServerSyncStatus.IS_SYNCED.rawValue,
shortId = highlight.highlightFields.shortId,
suffix = highlight.highlightFields.suffix,
updatedAt = highlight.highlightFields.updatedAt as String?,
createdAt = highlight.highlightFields.createdAt as String?,
color = highlight.highlightFields.color,
highlightPositionPercent = highlight.highlightFields.highlightPositionPercent,
highlightPositionAnchorIndex = highlight.highlightFields.highlightPositionAnchorIndex
)
})
}
)
}
return LibrarySearchQueryResponse(
cursor = newCursor,
items = searchItems
)
} catch (e: java.lang.Exception) {
return LibrarySearchQueryResponse(null, listOf())
}
return LibrarySearchQueryResponse(
cursor = newCursor, items = searchItems
)
} catch (e: java.lang.Exception) {
return LibrarySearchQueryResponse(null, listOf())
}
}

View File

@ -24,7 +24,7 @@ import app.omnivore.omnivore.core.network.RetrofitHelper
import app.omnivore.omnivore.core.network.SignInParams
import app.omnivore.omnivore.core.network.UserProfile
import app.omnivore.omnivore.core.network.viewer
import app.omnivore.omnivore.feature.ResourceProvider
import app.omnivore.omnivore.utils.ResourceProvider
import app.omnivore.omnivore.utils.Constants
import app.omnivore.omnivore.utils.DatastoreKeys
import com.apollographql.apollo3.ApolloClient

View File

@ -13,7 +13,7 @@ import app.omnivore.omnivore.R
import app.omnivore.omnivore.core.data.DataService
import app.omnivore.omnivore.graphql.generated.UpdatePageMutation
import app.omnivore.omnivore.graphql.generated.type.UpdatePageInput
import app.omnivore.omnivore.feature.ResourceProvider
import app.omnivore.omnivore.utils.ResourceProvider
import com.apollographql.apollo3.ApolloClient
import com.apollographql.apollo3.api.Optional
import dagger.hilt.android.lifecycle.HiltViewModel

View File

@ -69,7 +69,7 @@ class FollowingViewModel @Inject constructor(
initialValue = FollowingUiState.Loading
)
val appliedFilterLiveData = MutableLiveData<SavedItemFilter>(
val appliedFilterLiveData = MutableLiveData(
SavedItemFilter.FOLLOWING
)
val appliedSortFilterLiveData = MutableLiveData(SavedItemSortFilter.NEWEST)
@ -159,7 +159,7 @@ class FollowingViewModel @Inject constructor(
}
}
fun updateSavedItemFilter(filter: SavedItemFilter) {
private fun updateSavedItemFilter(filter: SavedItemFilter) {
viewModelScope.launch {
datastoreRepo.putString(DatastoreKeys.lastUsedSavedItemFilter, filter.rawValue)
appliedFilterLiveData.value = filter
@ -206,10 +206,9 @@ class FollowingViewModel @Inject constructor(
}
var requiredLabels = when (appliedFilterLiveData.value) {
SavedItemFilter.FOLLOWING -> listOf("Newsletter", "RSS")
SavedItemFilter.NEWSLETTERS -> listOf("Newsletter")
SavedItemFilter.FEEDS -> listOf("RSS")
else -> listOf("Newsletter", "RSS")//activeLabels.value.map { it.name }
else -> activeLabels.value.map { it.name }
}
activeLabels.value.let { it ->

View File

@ -51,7 +51,7 @@ class LibraryViewModel @Inject constructor(
allowedArchiveStates = listOf(0),
sortKey = "newest",
requiredLabels = listOf(),
excludedLabels = listOf(),
excludedLabels = listOf("Newsletter", "RSS"),
allowedContentReaders = listOf("WEB", "PDF", "EPUB")
)
)
@ -65,6 +65,7 @@ class LibraryViewModel @Inject constructor(
)
val appliedFilterLiveData = MutableLiveData<SavedItemFilter>()
val appliedSortFilterLiveData = MutableLiveData(SavedItemSortFilter.NEWEST)
val bottomSheetState = MutableLiveData(LibraryBottomSheetState.HIDDEN)
val currentItem = mutableStateOf<String?>(null)
@ -198,7 +199,6 @@ class LibraryViewModel @Inject constructor(
}
var requiredLabels = when (appliedFilterLiveData.value) {
SavedItemFilter.FOLLOWING -> listOf("Newsletter", "RSS")
SavedItemFilter.NEWSLETTERS -> listOf("Newsletter")
SavedItemFilter.FEEDS -> listOf("RSS")
else -> activeLabels.value.map { it.name }
@ -211,7 +211,7 @@ class LibraryViewModel @Inject constructor(
val excludeLabels = when (appliedFilterLiveData.value) {
SavedItemFilter.READ_LATER -> listOf("Newsletter", "RSS")
else -> listOf()
else -> listOf("Newsletter", "RSS")
}
_libraryQuery.value = LibraryQuery(

View File

@ -8,12 +8,13 @@ import androidx.compose.ui.text.font.FontWeight
enum class SavedItemFilter(val displayText: String, val rawValue: String, val queryString: String) {
FOLLOWING("Following", "following", "in:following use:folders"),
INBOX("Inbox", rawValue = "inbox", "in:inbox"),
INBOX("Inbox", rawValue = "inbox", "in:inbox use:folders"),
READ_LATER("Non-Feed Items", "nonFeed", "no:subscription"),
FEEDS("Feeds", "feeds", "in:inbox label:RSS"),
NEWSLETTERS("Newsletters", "newsletters", "in:inbox label:Newsletter"),
ALL("All", "all", "in:all"),
ARCHIVED("Archived", "archived", "in:archive"),
// HAS_HIGHLIGHTS("Highlighted", "hasHighlights", "has:highlights"),
FILES("Files", "files", "type:file"),
}

View File

@ -14,7 +14,7 @@ import app.omnivore.omnivore.core.datastore.DatastoreRepository
import app.omnivore.omnivore.R
import app.omnivore.omnivore.graphql.generated.SaveUrlMutation
import app.omnivore.omnivore.graphql.generated.type.SaveUrlInput
import app.omnivore.omnivore.feature.ResourceProvider
import app.omnivore.omnivore.utils.ResourceProvider
import com.apollographql.apollo3.ApolloClient
import com.apollographql.apollo3.api.Optional
import dagger.hilt.android.lifecycle.HiltViewModel