mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2025-12-10 06:42:07 +01:00
Add mutation to fetch the latest track data from the tracker (#920)
* Add mutation to fetch the latest track data from the tracker * Update Track.kt --------- Co-authored-by: Mitchell Syer <Syer10@users.noreply.github.com>
This commit is contained in:
@@ -135,6 +135,34 @@ class TrackMutation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class FetchTrackInput(
|
||||||
|
val clientMutationId: String? = null,
|
||||||
|
val recordId: Int,
|
||||||
|
)
|
||||||
|
|
||||||
|
data class FetchTrackPayload(
|
||||||
|
val clientMutationId: String?,
|
||||||
|
val trackRecord: TrackRecordType,
|
||||||
|
)
|
||||||
|
|
||||||
|
fun fetchTrack(input: FetchTrackInput): CompletableFuture<FetchTrackPayload> {
|
||||||
|
val (clientMutationId, recordId) = input
|
||||||
|
|
||||||
|
return future {
|
||||||
|
Track.refresh(recordId)
|
||||||
|
val trackRecord =
|
||||||
|
transaction {
|
||||||
|
TrackRecordTable.select {
|
||||||
|
TrackRecordTable.id eq recordId
|
||||||
|
}.first()
|
||||||
|
}
|
||||||
|
FetchTrackPayload(
|
||||||
|
clientMutationId,
|
||||||
|
TrackRecordType(trackRecord),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data class UnbindTrackInput(
|
data class UnbindTrackInput(
|
||||||
val clientMutationId: String? = null,
|
val clientMutationId: String? = null,
|
||||||
val recordId: Int,
|
val recordId: Int,
|
||||||
|
|||||||
@@ -187,6 +187,19 @@ object Track {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun refresh(recordId: Int) {
|
||||||
|
val recordDb =
|
||||||
|
transaction {
|
||||||
|
TrackRecordTable.select { TrackRecordTable.id eq recordId }.first()
|
||||||
|
}
|
||||||
|
|
||||||
|
val tracker = TrackerManager.getTracker(recordDb[TrackRecordTable.trackerId])!!
|
||||||
|
|
||||||
|
val track = recordDb.toTrack()
|
||||||
|
tracker.refresh(track)
|
||||||
|
upsertTrackRecord(track)
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun unbind(
|
suspend fun unbind(
|
||||||
recordId: Int,
|
recordId: Int,
|
||||||
deleteRemoteTrack: Boolean? = false,
|
deleteRemoteTrack: Boolean? = false,
|
||||||
|
|||||||
Reference in New Issue
Block a user