switched tanstack query
This commit is contained in:
@ -26,7 +26,7 @@
|
||||
SimklSyncRating,
|
||||
SimklSyncStatus
|
||||
} from "../../wailsjs/go/main/App";
|
||||
import type {TableItems} from "../helperTypes/TableTypes";
|
||||
import {AddAnimeServiceToTable} from "../helperComponents/AddAnimeServiceToTable.svelte";
|
||||
|
||||
let isAniListLoggedIn: boolean
|
||||
let isMalLoggedIn: boolean
|
||||
@ -60,9 +60,8 @@
|
||||
let startingAnilistStatusOption: StatusOption = statusOptions.filter(option => currentAniListAnime.data.MediaList.status === option.aniList)[0]
|
||||
const startedAtDate = convertAniListDateToString(currentAniListAnime.data.MediaList.startedAt)
|
||||
const completedAtDate = convertAniListDateToString(currentAniListAnime.data.MediaList.completedAt)
|
||||
let tableItems: TableItems = []
|
||||
|
||||
if (isAniListLoggedIn) tableItems.push({
|
||||
if (isAniListLoggedIn) AddAnimeServiceToTable({
|
||||
id: currentAniListAnime.data.MediaList.id,
|
||||
service: "AniList",
|
||||
progress: currentAniListAnime.data.MediaList.progress,
|
||||
@ -75,7 +74,7 @@
|
||||
})
|
||||
|
||||
|
||||
if (isMalLoggedIn) tableItems.push({
|
||||
if (isMalLoggedIn) AddAnimeServiceToTable({
|
||||
id: currentMalAnime.id,
|
||||
service: "MyAnimeList",
|
||||
progress: currentMalAnime.my_list_status.num_episodes_watched,
|
||||
@ -87,7 +86,7 @@
|
||||
notes: currentMalAnime.my_list_status.comments
|
||||
})
|
||||
|
||||
if (isSimklLoggedIn && Object.keys(currentSimklAnime).length > 0) tableItems.push({
|
||||
if (isSimklLoggedIn && Object.keys(currentSimklAnime).length > 0) AddAnimeServiceToTable({
|
||||
id: currentSimklAnime.show.ids.simkl,
|
||||
service: "Simkl",
|
||||
progress: currentSimklAnime.watched_episodes_count,
|
||||
@ -99,7 +98,6 @@
|
||||
notes: ""
|
||||
})
|
||||
|
||||
|
||||
const handleSubmit = async (e: any) => {
|
||||
submitting.set(true)
|
||||
let submitData: {
|
||||
@ -165,19 +163,17 @@
|
||||
newValue = value
|
||||
return newValue
|
||||
})
|
||||
for (const [index, tableItem] of tableItems.entries()) {
|
||||
if (tableItem.service === "AniList") {
|
||||
tableItems[index].id = currentAniListAnime.data.MediaList.id
|
||||
tableItems[index].service = "AniList"
|
||||
tableItems[index].progress = currentAniListAnime.data.MediaList.progress
|
||||
tableItems[index].status = currentAniListAnime.data.MediaList.status
|
||||
tableItems[index].startedAt = convertAniListDateToString(currentAniListAnime.data.MediaList.startedAt)
|
||||
tableItems[index].completedAt = convertAniListDateToString(currentAniListAnime.data.MediaList.completedAt)
|
||||
tableItems[index].score = currentAniListAnime.data.MediaList.score
|
||||
tableItems[index].repeat = currentAniListAnime.data.MediaList.repeat
|
||||
tableItems[index].notes = currentAniListAnime.data.MediaList.notes
|
||||
}
|
||||
}
|
||||
AddAnimeServiceToTable({
|
||||
id: currentAniListAnime.data.MediaList.id,
|
||||
service: "AniList",
|
||||
progress: currentAniListAnime.data.MediaList.progress,
|
||||
status: currentAniListAnime.data.MediaList.status,
|
||||
startedAt: convertAniListDateToString(currentAniListAnime.data.MediaList.startedAt),
|
||||
completedAt: convertAniListDateToString(currentAniListAnime.data.MediaList.completedAt),
|
||||
score: currentAniListAnime.data.MediaList.score,
|
||||
repeat: currentAniListAnime.data.MediaList.repeat,
|
||||
notes: currentAniListAnime.data.MediaList.notes,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@ -201,47 +197,54 @@
|
||||
value.my_list_status.comments = malAnimeReturn.comments
|
||||
return value
|
||||
})
|
||||
for (const [index, tableItem] of tableItems.entries()) {
|
||||
if (tableItem.service === "MyAnimeList") {
|
||||
tableItems[index].id = currentMalAnime.id
|
||||
tableItems[index].service = "MyAnimeList"
|
||||
tableItems[index].progress = currentMalAnime.my_list_status.num_episodes_watched
|
||||
tableItems[index].status = currentMalAnime.my_list_status.status
|
||||
tableItems[index].startedAt = currentMalAnime.my_list_status.start_date
|
||||
tableItems[index].completedAt = currentMalAnime.my_list_status.finish_date
|
||||
tableItems[index].score = currentMalAnime.my_list_status.score
|
||||
tableItems[index].repeat = currentMalAnime.my_list_status.num_times_rewatched
|
||||
tableItems[index].notes = currentMalAnime.my_list_status.comments
|
||||
}
|
||||
}
|
||||
AddAnimeServiceToTable({
|
||||
id: currentMalAnime.id,
|
||||
service: "MyAnimeList",
|
||||
progress: currentMalAnime.my_list_status.num_episodes_watched,
|
||||
status: currentMalAnime.my_list_status.status,
|
||||
startedAt: currentMalAnime.my_list_status.start_date,
|
||||
completedAt: currentMalAnime.my_list_status.finish_date,
|
||||
score: currentMalAnime.my_list_status.score,
|
||||
repeat: currentMalAnime.my_list_status.num_times_rewatched,
|
||||
notes: currentMalAnime.my_list_status.comments,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
if (simklLoggedIn) {
|
||||
if (currentSimklAnime.watched_episodes_count !== submitData.episodes) {
|
||||
await SimklSyncEpisodes(currentSimklAnime, submitData.episodes).then(value => {
|
||||
await SimklSyncEpisodes(currentSimklAnime, submitData.episodes).then((value: SimklAnime) => {
|
||||
AddAnimeServiceToTable({
|
||||
id: value.show.ids.simkl,
|
||||
service: "Simkl",
|
||||
progress: value.watched_episodes_count,
|
||||
status: value.status,
|
||||
startedAt: "",
|
||||
completedAt: "",
|
||||
score: value.user_rating,
|
||||
repeat: 0,
|
||||
notes: ""
|
||||
})
|
||||
simklAnime.update(newValue => {
|
||||
newValue = value
|
||||
return newValue
|
||||
})
|
||||
for (const [index, tableItem] of tableItems.entries()) {
|
||||
if (tableItem.service === "MyAnimeList") {
|
||||
tableItems[index].id = currentSimklAnime.show.ids.simkl
|
||||
tableItems[index].service = "Simkl"
|
||||
tableItems[index].progress = currentSimklAnime.watched_episodes_count
|
||||
tableItems[index].status = currentSimklAnime.status
|
||||
tableItems[index].startedAt = ""
|
||||
tableItems[index].completedAt = ""
|
||||
tableItems[index].score = currentSimklAnime.user_rating
|
||||
tableItems[index].repeat = 0
|
||||
tableItems[index].notes = ""
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (currentSimklAnime.user_rating !== submitData.rating) {
|
||||
await SimklSyncRating(currentSimklAnime, submitData.rating).then(value => {
|
||||
AddAnimeServiceToTable({
|
||||
id: value.show.ids.simkl,
|
||||
service: "Simkl",
|
||||
progress: value.watched_episodes_count,
|
||||
status: value.status,
|
||||
startedAt: "",
|
||||
completedAt: "",
|
||||
score: value.user_rating,
|
||||
repeat: 0,
|
||||
notes: ""
|
||||
})
|
||||
simklAnime.update(newValue => {
|
||||
newValue = value
|
||||
return newValue
|
||||
@ -251,6 +254,17 @@
|
||||
|
||||
if (currentSimklAnime.status !== submitData.status.simkl) {
|
||||
await SimklSyncStatus(currentSimklAnime, submitData.status.simkl).then(value => {
|
||||
AddAnimeServiceToTable({
|
||||
id: value.show.ids.simkl,
|
||||
service: "Simkl",
|
||||
progress: value.watched_episodes_count,
|
||||
status: value.status,
|
||||
startedAt: "",
|
||||
completedAt: "",
|
||||
score: value.user_rating,
|
||||
repeat: 0,
|
||||
notes: ""
|
||||
})
|
||||
simklAnime.update(newValue => {
|
||||
newValue = value
|
||||
return newValue
|
||||
@ -394,7 +408,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<AnimeTable items={tableItems}/>
|
||||
<AnimeTable/>
|
||||
|
||||
<div class="bg-white rounded-lg shadow max-w-4-4 dark:bg-gray-800">
|
||||
<div class="w-full mx-auto max-w-screen-xl p-4 md:flex md:items-center md:justify-end">
|
||||
|
Reference in New Issue
Block a user