|
|
|
@ -8,7 +8,6 @@
|
|
|
|
|
simklLoggedIn,
|
|
|
|
|
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
|
|
|
|
import { push } from "svelte-spa-router";
|
|
|
|
|
import { Button } from "flowbite-svelte";
|
|
|
|
|
import type { AniListGetSingleAnime } from "../anilist/types/AniListCurrentUserWatchListType";
|
|
|
|
|
import Rating from "./Rating.svelte";
|
|
|
|
|
import {
|
|
|
|
@ -23,15 +22,9 @@
|
|
|
|
|
} from "../mal/types/MALTypes";
|
|
|
|
|
import type { SimklAnime } from "../simkl/types/simklTypes";
|
|
|
|
|
import { writable } from "svelte/store";
|
|
|
|
|
import type {
|
|
|
|
|
StatusOption,
|
|
|
|
|
StatusOptions,
|
|
|
|
|
} from "../helperTypes/StatusTypes";
|
|
|
|
|
import type { StatusOption, StatusOptions } from "../helperTypes/StatusTypes";
|
|
|
|
|
import type { AniListUpdateVariables } from "../anilist/types/AniListTypes";
|
|
|
|
|
import {
|
|
|
|
|
convertDateStringToAniList,
|
|
|
|
|
convertDateToAniList,
|
|
|
|
|
} from "../helperFunctions/convertDateToAniList";
|
|
|
|
|
import { convertDateToAniList } from "../helperFunctions/convertDateToAniList";
|
|
|
|
|
import {
|
|
|
|
|
AniListDeleteEntry,
|
|
|
|
|
AniListUpdateEntry,
|
|
|
|
@ -83,8 +76,7 @@
|
|
|
|
|
{ id: 5, aniList: "REPEATING", mal: "rewatching", simkl: "watching" },
|
|
|
|
|
];
|
|
|
|
|
let startingAnilistStatusOption: StatusOption = statusOptions.filter(
|
|
|
|
|
(option) =>
|
|
|
|
|
currentAniListAnime.data.MediaList.status === option.aniList,
|
|
|
|
|
(option) => currentAniListAnime.data.MediaList.status === option.aniList,
|
|
|
|
|
)[0];
|
|
|
|
|
let startedAtDate: Date | null = convertAniListDateToDate(
|
|
|
|
|
currentAniListAnime.data.MediaList.startedAt,
|
|
|
|
@ -115,15 +107,11 @@
|
|
|
|
|
let startDate = "";
|
|
|
|
|
let finishDate = "";
|
|
|
|
|
if (currentMalAnime.my_list_status.start_date !== "") {
|
|
|
|
|
const startArray = re.exec(
|
|
|
|
|
currentMalAnime.my_list_status.start_date,
|
|
|
|
|
);
|
|
|
|
|
const startArray = re.exec(currentMalAnime.my_list_status.start_date);
|
|
|
|
|
startDate = `${startArray[2]}-${startArray[3]}-${startArray[1]}`;
|
|
|
|
|
}
|
|
|
|
|
if (currentMalAnime.my_list_status.finish_date !== "") {
|
|
|
|
|
const finishArray = re.exec(
|
|
|
|
|
currentMalAnime.my_list_status.finish_date,
|
|
|
|
|
);
|
|
|
|
|
const finishArray = re.exec(currentMalAnime.my_list_status.finish_date);
|
|
|
|
|
finishDate = `${finishArray[2]}-${finishArray[3]}-${finishArray[1]}`;
|
|
|
|
|
}
|
|
|
|
|
AddAnimeServiceToTable({
|
|
|
|
@ -200,10 +188,7 @@
|
|
|
|
|
submitData[key] = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
isAniListLoggedIn &&
|
|
|
|
|
currentAniListAnime.data.MediaList.mediaId !== 0
|
|
|
|
|
) {
|
|
|
|
|
if (isAniListLoggedIn && currentAniListAnime.data.MediaList.mediaId !== 0) {
|
|
|
|
|
let body: AniListUpdateVariables = {
|
|
|
|
|
mediaId: currentAniListAnime.data.MediaList.mediaId,
|
|
|
|
|
progress: submitData.episodes,
|
|
|
|
@ -214,8 +199,7 @@
|
|
|
|
|
startedAt: convertDateToAniList(startedAtDate),
|
|
|
|
|
completedAt: convertDateToAniList(completedAtDate),
|
|
|
|
|
};
|
|
|
|
|
await AniListUpdateEntry(body).then(
|
|
|
|
|
(value: AniListGetSingleAnime) => {
|
|
|
|
|
await AniListUpdateEntry(body).then((value: AniListGetSingleAnime) => {
|
|
|
|
|
/* TODO in future when you inevitably add tags to typescript, until Anilist fixes the api bug
|
|
|
|
|
where tags break the SaveMediaListEntry return, you'll want to use this delete line
|
|
|
|
|
delete value.data.MediaList.media.tags */
|
|
|
|
@ -239,8 +223,7 @@
|
|
|
|
|
repeat: currentAniListAnime.data.MediaList.repeat,
|
|
|
|
|
notes: currentAniListAnime.data.MediaList.notes,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (malLoggedIn && currentMalAnime.id !== 0) {
|
|
|
|
@ -257,8 +240,7 @@
|
|
|
|
|
(malAnimeReturn: MalListStatus) => {
|
|
|
|
|
malAnime.update((value) => {
|
|
|
|
|
value.my_list_status.status = malAnimeReturn.status;
|
|
|
|
|
value.my_list_status.is_rewatching =
|
|
|
|
|
malAnimeReturn.is_rewatching;
|
|
|
|
|
value.my_list_status.is_rewatching = malAnimeReturn.is_rewatching;
|
|
|
|
|
value.my_list_status.score = malAnimeReturn.score;
|
|
|
|
|
value.my_list_status.num_episodes_watched =
|
|
|
|
|
malAnimeReturn.num_episodes_watched;
|
|
|
|
@ -285,14 +267,12 @@
|
|
|
|
|
id: `m-${currentMalAnime.id}`,
|
|
|
|
|
title: currentMalAnime.title,
|
|
|
|
|
service: "MyAnimeList",
|
|
|
|
|
progress:
|
|
|
|
|
currentMalAnime.my_list_status.num_episodes_watched,
|
|
|
|
|
progress: currentMalAnime.my_list_status.num_episodes_watched,
|
|
|
|
|
status: currentMalAnime.my_list_status.status,
|
|
|
|
|
startedAt: startDate,
|
|
|
|
|
completedAt: finishDate,
|
|
|
|
|
score: currentMalAnime.my_list_status.score,
|
|
|
|
|
repeat: currentMalAnime.my_list_status
|
|
|
|
|
.num_times_rewatched,
|
|
|
|
|
repeat: currentMalAnime.my_list_status.num_times_rewatched,
|
|
|
|
|
notes: currentMalAnime.my_list_status.comments,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
@ -300,13 +280,9 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (simklLoggedIn && currentSimklAnime.show.ids.simkl !== 0) {
|
|
|
|
|
if (
|
|
|
|
|
currentSimklAnime.watched_episodes_count !== submitData.episodes
|
|
|
|
|
) {
|
|
|
|
|
await SimklSyncEpisodes(
|
|
|
|
|
currentSimklAnime,
|
|
|
|
|
submitData.episodes,
|
|
|
|
|
).then((value: SimklAnime) => {
|
|
|
|
|
if (currentSimklAnime.watched_episodes_count !== submitData.episodes) {
|
|
|
|
|
await SimklSyncEpisodes(currentSimklAnime, submitData.episodes).then(
|
|
|
|
|
(value: SimklAnime) => {
|
|
|
|
|
AddAnimeServiceToTable({
|
|
|
|
|
id: `s-${value.show.ids.simkl}`,
|
|
|
|
|
title: value.show.title,
|
|
|
|
@ -323,14 +299,13 @@
|
|
|
|
|
newValue = value;
|
|
|
|
|
return newValue;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (currentSimklAnime.user_rating !== submitData.rating) {
|
|
|
|
|
await SimklSyncRating(
|
|
|
|
|
currentSimklAnime,
|
|
|
|
|
submitData.rating,
|
|
|
|
|
).then((value) => {
|
|
|
|
|
await SimklSyncRating(currentSimklAnime, submitData.rating).then(
|
|
|
|
|
(value) => {
|
|
|
|
|
AddAnimeServiceToTable({
|
|
|
|
|
id: `s-${value.show.ids.simkl}`,
|
|
|
|
|
title: value.show.title,
|
|
|
|
@ -347,14 +322,13 @@
|
|
|
|
|
newValue = value;
|
|
|
|
|
return newValue;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (currentSimklAnime.status !== submitData.status.simkl) {
|
|
|
|
|
await SimklSyncStatus(
|
|
|
|
|
currentSimklAnime,
|
|
|
|
|
submitData.status.simkl,
|
|
|
|
|
).then((value) => {
|
|
|
|
|
await SimklSyncStatus(currentSimklAnime, submitData.status.simkl).then(
|
|
|
|
|
(value) => {
|
|
|
|
|
AddAnimeServiceToTable({
|
|
|
|
|
id: `s-${value.show.ids.simkl}`,
|
|
|
|
|
title: value.show.title,
|
|
|
|
@ -371,7 +345,8 @@
|
|
|
|
|
newValue = value;
|
|
|
|
|
return newValue;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -382,10 +357,7 @@
|
|
|
|
|
|
|
|
|
|
const deleteEntries = async () => {
|
|
|
|
|
submitting.set(true);
|
|
|
|
|
if (
|
|
|
|
|
isAniListLoggedIn &&
|
|
|
|
|
currentAniListAnime.data.MediaList.mediaId !== 0
|
|
|
|
|
) {
|
|
|
|
|
if (isAniListLoggedIn && currentAniListAnime.data.MediaList.mediaId !== 0) {
|
|
|
|
|
await AniListDeleteEntry(currentAniListAnime.data.MediaList.id);
|
|
|
|
|
AddAnimeServiceToTable({
|
|
|
|
|
id: `a-${currentAniListAnime.data.MediaList.mediaId}`,
|
|
|
|
@ -445,8 +417,7 @@
|
|
|
|
|
currentAniListAnime.data.MediaList.media.nextAiringEpisode.episode !== 0
|
|
|
|
|
) {
|
|
|
|
|
max =
|
|
|
|
|
currentAniListAnime.data.MediaList.media.nextAiringEpisode.episode -
|
|
|
|
|
1;
|
|
|
|
|
currentAniListAnime.data.MediaList.media.nextAiringEpisode.episode - 1;
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
@ -479,8 +450,17 @@
|
|
|
|
|
type="button"
|
|
|
|
|
id="decrement-button"
|
|
|
|
|
data-input-counter-decrement="quantity-input"
|
|
|
|
|
on:click={() =>
|
|
|
|
|
(currentAniListAnime.data.MediaList.progress -= 1)}
|
|
|
|
|
on:click={() => {
|
|
|
|
|
currentAniListAnime.data.MediaList.progress -= 1;
|
|
|
|
|
if (
|
|
|
|
|
currentAniListAnime.data.MediaList.progress <
|
|
|
|
|
currentAniListAnime.data.MediaList.media.episodes
|
|
|
|
|
) {
|
|
|
|
|
startingAnilistStatusOption = statusOptions[0];
|
|
|
|
|
if (currentAniListAnime.data.MediaList.repeat === 0)
|
|
|
|
|
completedAtDate = null;
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
class="bg-gray-700 hover:bg-gray-600 border-gray-600 border rounded-s-lg p-3 h-11 focus:ring-gray-700 focus:ring-2 focus:outline-none"
|
|
|
|
|
>
|
|
|
|
|
<svg
|
|
|
|
@ -507,30 +487,38 @@
|
|
|
|
|
id="episodes"
|
|
|
|
|
class="border border-x-0 p-2.5 h-11 text-center text-sm block w-full placeholder-gray-400 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none
|
|
|
|
|
{currentAniListAnime.data.MediaList.progress < 0 ||
|
|
|
|
|
(currentAniListAnime.data.MediaList.media.episodes >
|
|
|
|
|
0 &&
|
|
|
|
|
(currentAniListAnime.data.MediaList.media.episodes > 0 &&
|
|
|
|
|
currentAniListAnime.data.MediaList.progress >
|
|
|
|
|
currentAniListAnime.data.MediaList.media
|
|
|
|
|
.episodes) ||
|
|
|
|
|
(currentAniListAnime.data.MediaList.media
|
|
|
|
|
.nextAiringEpisode.episode > 0 &&
|
|
|
|
|
currentAniListAnime.data.MediaList.media.episodes) ||
|
|
|
|
|
(currentAniListAnime.data.MediaList.media.nextAiringEpisode
|
|
|
|
|
.episode > 0 &&
|
|
|
|
|
currentAniListAnime.data.MediaList.progress >
|
|
|
|
|
currentAniListAnime.data.MediaList.media
|
|
|
|
|
.nextAiringEpisode.episode -
|
|
|
|
|
currentAniListAnime.data.MediaList.media.nextAiringEpisode
|
|
|
|
|
.episode -
|
|
|
|
|
1)
|
|
|
|
|
? 'border-red-500 border-[2px] text-rose-300 focus:ring-red-500 focus:border-red-500'
|
|
|
|
|
: 'bg-gray-700 hover:bg-gray-600 border-gray-600 text-white focus:ring-blue-500 focus:border-blue-500'} w-24"
|
|
|
|
|
bind:value={
|
|
|
|
|
currentAniListAnime.data.MediaList.progress
|
|
|
|
|
}
|
|
|
|
|
bind:value={currentAniListAnime.data.MediaList.progress}
|
|
|
|
|
required
|
|
|
|
|
/>
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
id="increment-button"
|
|
|
|
|
data-input-counter-increment="quantity-input"
|
|
|
|
|
on:click={() =>
|
|
|
|
|
(currentAniListAnime.data.MediaList.progress += 1)}
|
|
|
|
|
on:click={() => {
|
|
|
|
|
currentAniListAnime.data.MediaList.progress += 1;
|
|
|
|
|
if (
|
|
|
|
|
currentAniListAnime.data.MediaList.media.episodes ===
|
|
|
|
|
currentAniListAnime.data.MediaList.progress
|
|
|
|
|
) {
|
|
|
|
|
startingAnilistStatusOption = statusOptions[2];
|
|
|
|
|
completedAtDate = new Date();
|
|
|
|
|
}
|
|
|
|
|
if (currentAniListAnime.data.MediaList.progress - 1 === 0) {
|
|
|
|
|
startingAnilistStatusOption = statusOptions[0];
|
|
|
|
|
if (startedAtDate === null) startedAtDate = new Date();
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
class="bg-gray-700 hover:bg-gray-600 border-gray-600 border rounded-e-lg p-3 h-11 focus:ring-gray-700 focus:ring-2 focus:outline-none"
|
|
|
|
|
>
|
|
|
|
|
<svg
|
|
|
|
@ -551,21 +539,37 @@
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
/ {currentAniListAnime.data.MediaList.media
|
|
|
|
|
.nextAiringEpisode.episode !== 0
|
|
|
|
|
? currentAniListAnime.data.MediaList.media
|
|
|
|
|
.nextAiringEpisode.episode - 1
|
|
|
|
|
/ {currentAniListAnime.data.MediaList.media.nextAiringEpisode
|
|
|
|
|
.episode !== 0
|
|
|
|
|
? currentAniListAnime.data.MediaList.media.nextAiringEpisode
|
|
|
|
|
.episode - 1
|
|
|
|
|
: currentAniListAnime.data.MediaList.media.episodes}
|
|
|
|
|
</div>
|
|
|
|
|
{#if currentAniListAnime.data.MediaList.media.nextAiringEpisode.episode !== 0}
|
|
|
|
|
<div>
|
|
|
|
|
of {currentAniListAnime.data.MediaList.media
|
|
|
|
|
.episodes}
|
|
|
|
|
of {currentAniListAnime.data.MediaList.media.episodes}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<label
|
|
|
|
|
for="status"
|
|
|
|
|
class="text-left block mb-2 text-sm font-medium text-white"
|
|
|
|
|
>Status</label
|
|
|
|
|
>
|
|
|
|
|
<select
|
|
|
|
|
id="status"
|
|
|
|
|
name="status"
|
|
|
|
|
class="border text-sm rounded-lg
|
|
|
|
|
block p-2.5 bg-gray-700 border-gray-600 placeholder-gray-400
|
|
|
|
|
text-white focus:ring-blue-500 focus:border-blue-500"
|
|
|
|
|
bind:value={startingAnilistStatusOption}
|
|
|
|
|
>
|
|
|
|
|
{#each statusOptions as option}
|
|
|
|
|
<option value={option}>{option.aniList}</option>
|
|
|
|
|
{/each}
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
class="flex flex-col md:flex-row md:pl-10 md:pr-10 pt-5 pb-5 justify-center md:gap-x-16 lg:gap-x-36"
|
|
|
|
@ -615,8 +619,7 @@
|
|
|
|
|
name="repeat"
|
|
|
|
|
min="0"
|
|
|
|
|
id="repeat"
|
|
|
|
|
class="border {currentAniListAnime.data.MediaList
|
|
|
|
|
.repeat < 0
|
|
|
|
|
class="border {currentAniListAnime.data.MediaList.repeat < 0
|
|
|
|
|
? 'border-red-500 border-[2px] text-rose-300 focus:ring-red-500 focus:border-red-500'
|
|
|
|
|
: 'border-gray-500 text-white focus:ring-blue-500 focus:border-blue-500'} text-sm rounded-lg block w-24 p-2.5 bg-gray-600 placeholder-gray-400 text-white"
|
|
|
|
|
bind:value={currentAniListAnime.data.MediaList.repeat}
|
|
|
|
@ -649,7 +652,7 @@
|
|
|
|
|
<div
|
|
|
|
|
class="w-full mx-auto max-w-screen-xl p-4 md:flex md:items-center md:justify-end"
|
|
|
|
|
>
|
|
|
|
|
<Button
|
|
|
|
|
<button
|
|
|
|
|
disabled={isSubmitting}
|
|
|
|
|
id="sync-button"
|
|
|
|
|
class="text-white {$submitSuccess
|
|
|
|
@ -678,8 +681,8 @@
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
Sync Changes
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
class="text-white bg-gray-800 border border-gray-600 focus:outline-none hover:bg-gray-700 focus:ring-4
|
|
|
|
|
focus:ring-gray-700 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2
|
|
|
|
|
hover:border-gray-600"
|
|
|
|
@ -689,7 +692,7 @@
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Go Home
|
|
|
|
|
</Button>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<AnimeTable />
|
|
|
|
@ -698,10 +701,10 @@
|
|
|
|
|
<div
|
|
|
|
|
class="w-full mx-auto max-w-screen-xl p-4 md:flex md:items-center md:justify-start"
|
|
|
|
|
>
|
|
|
|
|
<Button
|
|
|
|
|
<button
|
|
|
|
|
disabled={isSubmitting}
|
|
|
|
|
id="delete-button"
|
|
|
|
|
class="text-white bg-red-700 {$submitSuccess
|
|
|
|
|
class="text-white {$submitSuccess
|
|
|
|
|
? 'bg-green-600 hover:bg-green-700 focus:ring-4 focus:ring-green-800'
|
|
|
|
|
: 'bg-red-600 hover:bg-red-700 focus:ring-4 focus:ring-red-800'} font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 focus:outline-none"
|
|
|
|
|
on:click={deleteEntries}
|
|
|
|
@ -727,12 +730,12 @@
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
Delete Entries
|
|
|
|
|
</Button>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
class="w-full mx-auto max-w-screen-xl p-4 md:flex md:items-center md:justify-end"
|
|
|
|
|
>
|
|
|
|
|
<Button
|
|
|
|
|
<button
|
|
|
|
|
disabled={isSubmitting}
|
|
|
|
|
id="sync-button"
|
|
|
|
|
class="text-white {$submitSuccess
|
|
|
|
@ -761,8 +764,8 @@
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
Sync Changes
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
class="text-white bg-gray-800 border border-gray-600 focus:outline-none hover:bg-gray-700 focus:ring-4
|
|
|
|
|
focus:ring-gray-700 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2
|
|
|
|
|
hover:border-gray-600"
|
|
|
|
@ -772,7 +775,7 @@
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Go Home
|
|
|
|
|
</Button>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|