-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add graphql mutation for library progress updates
- Loading branch information
Showing
13 changed files
with
206 additions
and
86 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
app/src/main/graphql/fragment/LibraryEntryWithNextUnitFragment.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
fragment LibraryEntryWithNextUnitFragment on LibraryEntry { | ||
...LibraryEntryFragment | ||
nextUnit { | ||
id | ||
number | ||
thumbnail { | ||
original { | ||
url | ||
} | ||
} | ||
titles { | ||
...TitlesFragment | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/graphql/mutation/UpdateLibraryEntryProgress.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
mutation UpdateLibraryEntryProgress($entryId: ID!, $progress: Int!) { | ||
libraryEntry { | ||
updateProgressById(input: { id: $entryId, progress: $progress }) { | ||
libraryEntry { | ||
...LibraryEntryWithNextUnitFragment | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 4 additions & 61 deletions
65
...java/io/github/drumber/kitsune/data/mapper/graphql/GetLibraryEntriesWithNextUnitMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,10 @@ | ||
package io.github.drumber.kitsune.data.mapper.graphql | ||
|
||
import io.github.drumber.kitsune.data.common.Image | ||
import io.github.drumber.kitsune.data.presentation.model.library.LibraryEntryWithModification | ||
import io.github.drumber.kitsune.data.presentation.model.library.LibraryEntryWithModificationAndNextUnit | ||
import io.github.drumber.kitsune.data.presentation.model.media.unit.Chapter | ||
import io.github.drumber.kitsune.data.presentation.model.media.unit.Episode | ||
import io.github.drumber.kitsune.data.source.graphql.GetLibraryEntriesWithNextUnitQuery | ||
|
||
fun GetLibraryEntriesWithNextUnitQuery.All.toLibraryEntriesWithModificationAndNextUnit() = nodes | ||
fun GetLibraryEntriesWithNextUnitQuery.All.toLibraryEntriesWithNextUnit() = nodes | ||
?.filterNotNull() | ||
?.map(GetLibraryEntriesWithNextUnitQuery.Node::toLibraryEntriesWithModificationAndNextUnit) | ||
?.map(GetLibraryEntriesWithNextUnitQuery.Node::toLibraryEntryWithNextUnit) | ||
|
||
fun GetLibraryEntriesWithNextUnitQuery.Node.toLibraryEntriesWithModificationAndNextUnit() = | ||
LibraryEntryWithModificationAndNextUnit( | ||
LibraryEntryWithModification( | ||
libraryEntryFragment.toLibraryEntry(), | ||
null | ||
), | ||
nextUnit?.toMediaUnit(libraryEntryFragment.media.libraryMediaFragment.type) | ||
) | ||
|
||
fun GetLibraryEntriesWithNextUnitQuery.NextUnit.toMediaUnit(mediaType: String) = | ||
when (mediaType) { | ||
"Anime" -> toEpisode() | ||
"Manga" -> toChapter() | ||
else -> null | ||
} | ||
|
||
fun GetLibraryEntriesWithNextUnitQuery.NextUnit.toEpisode() = Episode( | ||
id = id, | ||
description = null, | ||
titles = titles.titlesFragment.toTitles(), | ||
canonicalTitle = titles.titlesFragment.canonical, | ||
number = number, | ||
seasonNumber = null, | ||
relativeNumber = null, | ||
length = null, | ||
airdate = null, | ||
thumbnail = Image( | ||
tiny = null, | ||
small = null, | ||
medium = null, | ||
large = null, | ||
original = thumbnail?.original?.url, | ||
meta = null | ||
) | ||
) | ||
|
||
fun GetLibraryEntriesWithNextUnitQuery.NextUnit.toChapter() = Chapter( | ||
id = id, | ||
description = null, | ||
titles = titles.titlesFragment.toTitles(), | ||
canonicalTitle = titles.titlesFragment.canonical, | ||
number = number, | ||
volumeNumber = null, | ||
length = null, | ||
thumbnail = Image( | ||
tiny = null, | ||
small = null, | ||
medium = null, | ||
large = null, | ||
original = thumbnail?.original?.url, | ||
meta = null | ||
), | ||
published = null | ||
) | ||
fun GetLibraryEntriesWithNextUnitQuery.Node.toLibraryEntryWithNextUnit() = | ||
libraryEntryWithNextUnitFragment.toLibraryEntryWithNextUnit() |
58 changes: 58 additions & 0 deletions
58
...a/io/github/drumber/kitsune/data/mapper/graphql/LibraryEntryWithNextUnitFragmentMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package io.github.drumber.kitsune.data.mapper.graphql | ||
|
||
import io.github.drumber.kitsune.data.common.Image | ||
import io.github.drumber.kitsune.data.presentation.model.library.LibraryEntryWithNextUnit | ||
import io.github.drumber.kitsune.data.presentation.model.media.unit.Chapter | ||
import io.github.drumber.kitsune.data.presentation.model.media.unit.Episode | ||
import io.github.drumber.kitsune.data.source.graphql.fragment.LibraryEntryWithNextUnitFragment | ||
|
||
fun LibraryEntryWithNextUnitFragment.toLibraryEntryWithNextUnit() = LibraryEntryWithNextUnit( | ||
libraryEntry = libraryEntryFragment.toLibraryEntry(), | ||
nextUnit = nextUnit?.toMediaUnit(libraryEntryFragment.media.libraryMediaFragment.type) | ||
) | ||
|
||
fun LibraryEntryWithNextUnitFragment.NextUnit.toMediaUnit(mediaType: String) = | ||
when (mediaType) { | ||
"Anime" -> toEpisode() | ||
"Manga" -> toChapter() | ||
else -> null | ||
} | ||
|
||
fun LibraryEntryWithNextUnitFragment.NextUnit.toEpisode() = Episode( | ||
id = id, | ||
description = null, | ||
titles = titles.titlesFragment.toTitles(), | ||
canonicalTitle = titles.titlesFragment.canonical, | ||
number = number, | ||
seasonNumber = null, | ||
relativeNumber = null, | ||
length = null, | ||
airdate = null, | ||
thumbnail = Image( | ||
tiny = null, | ||
small = null, | ||
medium = null, | ||
large = null, | ||
original = thumbnail?.original?.url, | ||
meta = null | ||
) | ||
) | ||
|
||
fun LibraryEntryWithNextUnitFragment.NextUnit.toChapter() = Chapter( | ||
id = id, | ||
description = null, | ||
titles = titles.titlesFragment.toTitles(), | ||
canonicalTitle = titles.titlesFragment.canonical, | ||
number = number, | ||
volumeNumber = null, | ||
length = null, | ||
thumbnail = Image( | ||
tiny = null, | ||
small = null, | ||
medium = null, | ||
large = null, | ||
original = thumbnail?.original?.url, | ||
meta = null | ||
), | ||
published = null | ||
) |
8 changes: 8 additions & 0 deletions
8
...ava/io/github/drumber/kitsune/data/presentation/model/library/LibraryEntryWithNextUnit.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.github.drumber.kitsune.data.presentation.model.library | ||
|
||
import io.github.drumber.kitsune.data.presentation.model.media.unit.MediaUnit | ||
|
||
data class LibraryEntryWithNextUnit( | ||
val libraryEntry: LibraryEntry, | ||
val nextUnit: MediaUnit? | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.