add graphql files for archiving and deleting in android

This commit is contained in:
Satindar Dhillon 2022-12-12 13:58:55 -08:00
parent f7f2bce153
commit 6e1182d163
3 changed files with 50 additions and 0 deletions

View file

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

View file

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

View file

@ -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
}