mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
add graphql files for archiving and deleting in android
This commit is contained in:
parent
f7f2bce153
commit
6e1182d163
3 changed files with 50 additions and 0 deletions
|
|
@ -0,0 +1,12 @@
|
|||
mutation SetLinkArchived($input: ArchiveLinkInput!) {
|
||||
setLinkArchived(input: $input) {
|
||||
... on ArchiveLinkSuccess {
|
||||
linkId
|
||||
message
|
||||
}
|
||||
... on ArchiveLinkError {
|
||||
message
|
||||
errorCodes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
mutation SetBookmarkArticle($input: SetBookmarkArticleInput!) {
|
||||
setBookmarkArticle(input: $input) {
|
||||
... on SetBookmarkArticleSuccess {
|
||||
bookmarkedArticle {
|
||||
id
|
||||
}
|
||||
}
|
||||
... on SetBookmarkArticleError {
|
||||
errorCodes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package app.omnivore.omnivore.networking
|
||||
|
||||
import app.omnivore.omnivore.graphql.generated.SetBookmarkArticleMutation
|
||||
import app.omnivore.omnivore.graphql.generated.SetLinkArchivedMutation
|
||||
import app.omnivore.omnivore.graphql.generated.type.ArchiveLinkInput
|
||||
import app.omnivore.omnivore.graphql.generated.type.SetBookmarkArticleInput
|
||||
|
||||
suspend fun Networker.deleteLinkedItem(itemID: String): Boolean {
|
||||
val input = SetBookmarkArticleInput(itemID, false)
|
||||
val result = authenticatedApolloClient().mutation(SetBookmarkArticleMutation(input)).execute()
|
||||
return result.data?.setBookmarkArticle?.onSetBookmarkArticleSuccess?.bookmarkedArticle?.id != null
|
||||
}
|
||||
|
||||
suspend fun Networker.archiveLinkedItem(itemID: String): Boolean {
|
||||
return updateArchiveStatusLinkedItem(itemID, true)
|
||||
}
|
||||
|
||||
suspend fun Networker.unarchiveLinkedItem(itemID: String): Boolean {
|
||||
return updateArchiveStatusLinkedItem(itemID, false)
|
||||
}
|
||||
|
||||
private suspend fun Networker.updateArchiveStatusLinkedItem(itemID: String, setAsArchived: Boolean): Boolean {
|
||||
val input = ArchiveLinkInput(setAsArchived, itemID)
|
||||
val result = authenticatedApolloClient().mutation(SetLinkArchivedMutation(input)).execute()
|
||||
return result.data?.setLinkArchived?.onArchiveLinkSuccess?.linkId != null
|
||||
}
|
||||
Loading…
Reference in a new issue