rewrote the Anime.svelte to move out helper functions and clean up code

This commit is contained in:
John O'Keefe 2024-09-05 15:29:42 -04:00
parent aeec8f79b2
commit 77e361b5b2
20 changed files with 616 additions and 473 deletions

View File

@ -355,7 +355,7 @@ func (a *App) GetAniListUserWatchingList(page int, perPage int, sort string) Ani
return post
}
func (a *App) AniListUpdateEntry(updateBody AniListUpdateVariables) interface{} {
func (a *App) AniListUpdateEntry(updateBody AniListUpdateVariables) AniListGetSingleAnime {
body := struct {
Query string `json:"query"`
Variables AniListUpdateVariables `json:"variables"`
@ -381,12 +381,33 @@ func (a *App) AniListUpdateEntry(updateBody AniListUpdateVariables) interface{}
startedAt:$startedAt
completedAt:$completedAt
){
id
mediaId
progress
userId
media {
id
idMal
title {
romaji
english
native
}
description
coverImage {
large
}
season
seasonYear
status
episodes
nextAiringEpisode {
airingAt
timeUntilAiring
episode
}
isAdult
}
status
score
repeat
notes
startedAt{
year
month
@ -397,6 +418,27 @@ func (a *App) AniListUpdateEntry(updateBody AniListUpdateVariables) interface{}
month
day
}
notes
progress
score
repeat
user {
id
name
avatar{
large
medium
}
statistics{
anime{
count
statuses{
status
count
}
}
}
}
}
}
`,
@ -405,11 +447,15 @@ func (a *App) AniListUpdateEntry(updateBody AniListUpdateVariables) interface{}
returnedBody, _ := AniListQuery(body, true)
var post interface{}
err := json.Unmarshal(returnedBody, &post)
var returnedJson AniListUpdateReturn
err := json.Unmarshal(returnedBody, &returnedJson)
if err != nil {
log.Printf("Failed at unmarshal, %s\n", err)
}
var post AniListGetSingleAnime
post.Data.MediaList = returnedJson.Data.SaveMediaListEntry
return post
}

View File

@ -43,6 +43,12 @@ type AniListGetSingleAnime struct {
} `json:"data"`
}
type AniListUpdateReturn struct {
Data struct {
SaveMediaListEntry MediaList `json:"SaveMediaListEntry"`
}
}
type MediaList struct {
ID int `json:"id"`
MediaID int `json:"mediaId"`

View File

@ -55,7 +55,7 @@ func (a *App) GetMyAnimeList(count int) MALWatchlist {
return malList
}
func (a *App) MyAnimeListUpdate(anime MALAnime, update MALUploadStatus) MyListStatus {
func (a *App) MyAnimeListUpdate(anime MALAnime, update MALUploadStatus) MalListStatus {
if update.NumTimesRewatched >= 1 {
update.IsRewatching = true
} else {
@ -70,7 +70,7 @@ func (a *App) MyAnimeListUpdate(anime MALAnime, update MALUploadStatus) MyListSt
body.Set("comments", update.Comments)
malUrl := "https://api.myanimelist.net/v2/anime/" + strconv.Itoa(anime.Id) + "/my_list_status"
var status MyListStatus
var status MalListStatus
respBody := MALHelper("PATCH", malUrl, body)
err := json.Unmarshal(respBody, &status)
if err != nil {

View File

@ -91,13 +91,13 @@ type MALAnime struct {
Id int `json:"id" ts_type:"id"`
Name string `json:"name" ts_type:"name"`
} `json:"genres" ts_type:"genres"`
CreatedAt string `json:"created_at" ts_type:"createdAt"`
UpdatedAt string `json:"updated_at" ts_type:"updatedAt"`
MediaType string `json:"media_type" ts_type:"mediaType"`
Status string `json:"status" ts_type:"status"`
MyListStatus MyListStatus `json:"my_list_status" ts_type:"myListStatus"`
NumEpisodes int `json:"num_episodes" ts_type:"numEpisodes"`
StartSeason struct {
CreatedAt string `json:"created_at" ts_type:"createdAt"`
UpdatedAt string `json:"updated_at" ts_type:"updatedAt"`
MediaType string `json:"media_type" ts_type:"mediaType"`
Status string `json:"status" ts_type:"status"`
MalListStatus MalListStatus `json:"my_list_status" ts_type:"MalListStatus"`
NumEpisodes int `json:"num_episodes" ts_type:"numEpisodes"`
StartSeason struct {
Year int `json:"year" ts_type:"year"`
Season string `json:"season" ts_type:"season"`
} `json:"start_season" ts_type:"startSeason"`
@ -138,7 +138,7 @@ type MALAnime struct {
}
}
type MyListStatus struct {
type MalListStatus struct {
Status string `json:"status" ts_type:"status"`
Score int `json:"score" ts_type:"score"`
NumEpisodesWatched int `json:"num_episodes_watched" ts_type:"numEpisodesWatched"`

View File

@ -93,7 +93,7 @@ body:graphql {
body:graphql:vars {
{
"userId": 413504,
"mediaId": 110,
"mediaId": 1,
"listType": "ANIME"
}
}

View File

@ -19,12 +19,33 @@ headers {
body:graphql {
mutation($mediaId:Int, $progress:Int, $status:MediaListStatus){
SaveMediaListEntry(mediaId:$mediaId, progress:$progress, status:$status){
id
mediaId
progress
userId
media {
id
idMal
title {
romaji
english
native
}
description
coverImage {
large
}
season
seasonYear
status
episodes
nextAiringEpisode {
airingAt
timeUntilAiring
episode
}
isAdult
}
status
score
repeat
notes
startedAt{
year
month
@ -35,14 +56,35 @@ body:graphql {
month
day
}
notes
progress
score
repeat
user {
id
name
avatar{
large
medium
}
statistics{
anime{
count
statuses{
status
count
}
}
}
}
}
}
}
body:graphql:vars {
{
"mediaId": 1,
"progress": 26,
"mediaId": 169417,
"progress": 12,
"status":"COMPLETED"
}
}

View File

@ -26,6 +26,7 @@
},
"dependencies": {
"@popperjs/core": "^2.11.8",
"@tanstack/svelte-table": "^8.20.5",
"flowbite": "^2.4.1",
"flowbite-svelte": "^0.46.15",
"moment": "^2.30.1"

View File

@ -112,6 +112,7 @@
'/anime/:id': wrap({
asyncComponent: () => import('./routes/Anime.svelte'),
conditions: [
() => $aniListLoggedIn,
async (detail) => {
await GetAniListSingleItem(Number(detail.params.id), true)
return Object.keys($aniListAnime).length!==0

View File

@ -0,0 +1,33 @@
<script lang="ts" context="module">
import type {TableItem} from "../helperTypes/TableTypes";
import { tableItems } from "./GlobalVariablesAndHelperFunctions.svelte"
export function AddAnimeServiceToTable(tableItem: TableItem) {
let tableLoaded: TableItem[]
tableItems.subscribe(value => tableLoaded = value)
console.log(tableLoaded.length)
if(tableLoaded.length === 0) {
tableItems.update(table => {
table.push(tableItem)
return table
})
return
}
for (const [index, entry] of tableLoaded.entries()) {
console.log(entry)
if (entry.service === tableItem.service) {
tableItems.update(value => {
value[index] = tableItem
return value
})
} else {
tableItems.update(table => {
table.push(tableItem)
return table
})
}
}
return
}
</script>

View File

@ -0,0 +1,68 @@
<script lang="ts">
import {Table, TableBody, TableBodyCell, TableBodyRow, TableHead, TableHeadCell} from "flowbite-svelte";
import {writable} from "svelte/store";
import type {TableItems} from "../helperTypes/TableTypes";
export let items: TableItems
// tableItems.subscribe(value => items = value)
const sortKey = writable('service'); // default sort key
const sortDirection = writable(1); // default sort direction (ascending)
const sortItems = writable(items.slice()); // make a copy of the items array
// Define a function to sort the items
const sortTable = (key: any) => {
// If the same key is clicked, reverse the sort direction
if ($sortKey === key) {
sortDirection.update((val) => -val);
} else {
sortKey.set(key);
sortDirection.set(1);
}
};
$: {
const key = $sortKey;
const direction = $sortDirection;
const sorted = [...$sortItems].sort((a, b) => {
const aVal = a[key];
const bVal = b[key];
if (aVal < bVal) {
return -direction;
} else if (aVal > bVal) {
return direction;
}
return 0;
});
sortItems.set(sorted);
}
</script>
<Table hoverable={true}>
<TableHead>
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('id')}>ID</TableHeadCell>
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('service')}>Service</TableHeadCell>
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('progress')}>Episode Progress</TableHeadCell>
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('status')}>Status</TableHeadCell>
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('startedAt')}>Date Started</TableHeadCell>
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('completedAt')}>Date Completed</TableHeadCell>
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('score')}>Rating</TableHeadCell>
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('repeat')}>Rewatches</TableHeadCell>
<TableHeadCell>Notes</TableHeadCell>
</TableHead>
<TableBody tableBodyClass="divide-y">
{#each $sortItems as item}
<TableBodyRow>
<TableBodyCell class="overflow-x-auto">{item.id}</TableBodyCell>
<TableBodyCell class="overflow-x-auto">{item.service}</TableBodyCell>
<TableBodyCell class="overflow-x-auto">{item.progress}</TableBodyCell>
<TableBodyCell class="overflow-x-auto">{item.status}</TableBodyCell>
<TableBodyCell class="overflow-x-auto">{item.startedAt}</TableBodyCell>
<TableBodyCell class="overflow-x-auto">{item.completedAt}</TableBodyCell>
<TableBodyCell class="overflow-x-auto">{item.score}</TableBodyCell>
<TableBodyCell class="overflow-x-auto">{item.repeat}</TableBodyCell>
<TableBodyCell class="overflow-x-auto">{item.notes}</TableBodyCell>
</TableBodyRow>
{/each}
</TableBody>
</Table>

View File

@ -20,6 +20,7 @@
import type {SimklAnime, SimklUser, SimklWatchList} from "../simkl/types/simklTypes";
import {type AniListUser, MediaListSort} from "../anilist/types/AniListTypes";
import type {MALAnime, MALWatchlist, MyAnimeListUser} from "../mal/types/MALTypes";
import type {TableItems} from "../helperTypes/TableTypes";
export let aniListAnime = writable({} as AniListGetSingleAnime)
export let title = writable("")
@ -38,6 +39,7 @@
export let malAnime = writable({} as MALAnime)
export let simklAnime = writable({} as SimklAnime)
export let loading = writable(false)
export let tableItems = writable([] as TableItems)
export let watchListPage = writable(1)
export let animePerPage = writable(20)

View File

@ -0,0 +1,50 @@
<script lang="ts">
import StarRatting from "../star-rating/Stars.svelte";
export let score
let config = {
readOnly: false,
countStars: 5,
range: {
min: 0,
max: 5,
step: 0.5
},
score: score / 2,
showScore: false,
name: "rating",
scoreFormat: function(){ return `(${this.score.toFixed(0)}/${this.countStars})` },
starConfig: {
size: 32,
fillColor: '#F9ED4F',
strokeColor: "#e2c714",
unfilledColor: '#FFF',
strokeUnfilledColor: '#000'
}
}
const ratingInWords = {
0: "Not Reviewed",
1: "Appalling",
2: "Horrible",
3: "Very Bad",
4: "Bad",
5: "Average",
6: "Fine",
7: "Good",
8: "Very Good",
9: "Great",
10: "Masterpiece",
}
const changeRating = (e: any) => {
score = e.target.valueAsNumber * 2
}
</script>
<div>
<StarRatting bind:config on:change={changeRating}/>
<p>Rating: {config.score * 2}</p>
<p>{ratingInWords[config.score * 2]}</p>
</div>

View File

@ -0,0 +1,17 @@
import moment from "moment";
export default (date: {
year?: number,
month?: number,
day?: number,
}): string => {
if (date.year === undefined || date.year === 0
&& date.month === undefined || date.month === 0
&& date.day === undefined || date.day === 0
) {
return ""
}
const newISODate = new Date(date.year, date.month - 1, date.day)
const newMoment = moment(newISODate)
return newMoment.format('YYYY-MM-DD')
}

View File

@ -0,0 +1,22 @@
type Date = {
year: number,
month: number,
day: number,
}
export default (date: string): Date => {
if (date === "") {
return {
year: 0,
month: 0,
day: 0,
}
}
const re = /^([0-9]{4})-([0-9]{2})-([0-9]{2})/
const newDate = re.exec(date)
return {
year: Number(newDate[1]),
month: Number(newDate[2]),
day: Number(newDate[3])
}
}

View File

@ -0,0 +1,8 @@
export type StatusOptions = StatusOption[]
export type StatusOption = {
id: number,
aniList: string,
mal: string,
simkl: string,
}

View File

@ -0,0 +1,13 @@
export type TableItems = TableItem[]
export type TableItem = {
id: number
service: string
progress: number
status: string
startedAt: string
completedAt: string
score: number
repeat: number
notes: string
}

View File

@ -37,7 +37,7 @@ export interface MALWatchlist {
export interface MALAnimeFromList {
node: Node
listStatus: ListStatus | MyListStatus
listStatus: ListStatus | MalListStatus
}
export interface Node {
@ -51,15 +51,6 @@ export interface MainPicture {
large: string
}
export interface ListStatus {
status: string
score: number
numEpisodesWatched: number
isRewatching: boolean
updated_at: string
startDate: string
finishDate: string
}
export interface Paging {
previous: string
@ -95,7 +86,7 @@ export interface MALAnime {
updated_at: string;
media_type: string;
status: string;
my_list_status: MyListStatus;
my_list_status: MalListStatus;
num_episodes: number;
start_season: {
year: number;
@ -138,7 +129,7 @@ export interface MALAnime {
};
}
export interface MyListStatus {
export interface MalListStatus {
status: string;
score: number;
num_episodes_watched: number;
@ -160,4 +151,14 @@ export interface MALUploadStatus {
num_watched_episodes: number
num_times_rewatched: number
comments: string
}
export interface ListStatus {
status: string
score: number
numEpisodesWatched: number
isRewatching: boolean
updated_at: string
startDate: string
finishDate: string
}

View File

@ -1,426 +1,282 @@
<script lang="ts">
import {
aniListLoggedIn,
simklLoggedIn,
malLoggedIn,
malAnime,
simklAnime,
aniListAnime,
aniListLoggedIn,
malAnime,
malLoggedIn,
simklAnime,
simklLoggedIn,
} from "../helperComponents/GlobalVariablesAndHelperFunctions.svelte";
import {pop} from "svelte-spa-router";
import {Button} from "flowbite-svelte";
// @ts-ignore
import StarRatting from "../star-rating/Stars.svelte"
import moment from 'moment'
import { Table, TableBody, TableBodyCell, TableBodyRow, TableHead, TableHeadCell } from 'flowbite-svelte';
import { writable } from 'svelte/store';
import type {AniListGetSingleAnime} from "../anilist/types/AniListCurrentUserWatchListType";
import Rating from "../helperComponents/Rating.svelte";
import convertAniListDateToString from "../helperFunctions/convertAniListDateToString";
import AnimeTable from "../helperComponents/AnimeTable.svelte";
import type {MALAnime, MalListStatus, MALUploadStatus} 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 {AniListUpdateVariables} from "../anilist/types/AniListTypes";
import convertDateStringToAniList from "../helperFunctions/convertDateStringToAniList";
import {
AniListUpdateEntry, MyAnimeListUpdate,
AniListUpdateEntry,
MyAnimeListUpdate,
SimklSyncEpisodes,
SimklSyncRating,
SimklSyncStatus
} from "../../wailsjs/go/main/App";
import type {MALAnime, MALUploadStatus, MyListStatus} from "../mal/types/MALTypes";
import type {AniListUpdateVariables} from "../anilist/types/AniListTypes";
import type {AniListGetSingleAnime} from "../anilist/types/AniListCurrentUserWatchListType";
import {pop} from "svelte-spa-router";
import type {TableItems} from "../helperTypes/TableTypes";
let isAniListLoggedIn: boolean
let isMalLoggedIn: boolean
let isSimklLoggedIn: boolean
let currentAniListAnime: AniListGetSingleAnime
let currentMalAnime: MALAnime
let currentSimklAnime: SimklAnime
let submitting = writable(false)
let isSubmitting: boolean
let currentAniListAnime: AniListGetSingleAnime
let isSubmitSuccess = false
let submitSuccess = writable(false)
aniListLoggedIn.subscribe((value) => isAniListLoggedIn = value)
malLoggedIn.subscribe((value) => isMalLoggedIn = value)
simklLoggedIn.subscribe((value) => isSimklLoggedIn = value)
malAnime.subscribe((value) => currentMalAnime = value)
submitting.subscribe((value) => isSubmitting = value)
simklAnime.subscribe((value) => currentSimklAnime = value)
aniListAnime.subscribe((value) => currentAniListAnime = value)
type statusOption = {
id: number,
aniList: string,
mal: string,
simkl: string,
}
const statusOptions: statusOption[] = [
{ id: 0, aniList: "CURRENT", mal: "watching", simkl: "watching"},
{ id: 1, aniList: "PLANNING", mal: "plan_to_watch", simkl: "plantowatch"},
{ id: 2, aniList: "COMPLETED", mal: "completed", simkl: "completed"},
{ id: 3, aniList: "DROPPED", mal: "dropped", simkl: "dropped"},
{ id: 4, aniList: "PAUSED", mal: "on_hold", simkl: "hold"},
{ id: 5, aniList: "REPEATING", mal: "rewatching", simkl: "watching"}
]
let startingAnilistStatusOption: statusOption
startingAnilistStatusOption = statusOptions.filter(option => currentAniListAnime.data.MediaList.status === option.aniList)[0]
type TableItems = {
id: number
service: string
progress: number
status: string
startedAt: string
completedAt: string
score: number
repeat: number
notes: string
}[]
let items = writable([] as TableItems);
let tableItems: TableItems
items.subscribe(value => tableItems = value)
if(isAniListLoggedIn) {
items.update(item => {
item.push({
id: currentAniListAnime.data.MediaList.id,
service: "AniList",
progress: currentAniListAnime.data.MediaList.progress,
status: currentAniListAnime.data.MediaList.status,
startedAt: `${currentAniListAnime.data.MediaList.startedAt.month}-${currentAniListAnime.data.MediaList.startedAt.day}-${currentAniListAnime.data.MediaList.startedAt.year}`,
completedAt: `${currentAniListAnime.data.MediaList.completedAt.month}-${currentAniListAnime.data.MediaList.completedAt.day}-${currentAniListAnime.data.MediaList.completedAt.year}`,
score: currentAniListAnime.data.MediaList.score,
repeat: currentAniListAnime.data.MediaList.repeat,
notes: currentAniListAnime.data.MediaList.notes
})
return item
})
}
if(isMalLoggedIn) {
items.update(item => {
item.push({
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
})
return item
})
}
if(isSimklLoggedIn && Object.keys(currentSimklAnime).length > 0) {
items.update(item => {
item.push({
id: currentSimklAnime.show.ids.simkl,
service: "Simkl",
progress: currentSimklAnime.watched_episodes_count,
status: currentSimklAnime.status,
startedAt: "",
completedAt: "",
score: currentSimklAnime.user_rating,
repeat: 0,
notes: ""
})
return item
})
}
const sortKey = writable('service'); // default sort key
const sortDirection = writable(1); // default sort direction (ascending)
const sortItems = writable(tableItems.slice()); // make a copy of the items array
// Define a function to sort the items
const sortTable = (key: any) => {
// If the same key is clicked, reverse the sort direction
if ($sortKey === key) {
sortDirection.update((val) => -val);
} else {
sortKey.set(key);
sortDirection.set(1);
}
};
$: {
const key = $sortKey;
const direction = $sortDirection;
const sorted = [...$sortItems].sort((a, b) => {
const aVal = a[key];
const bVal = b[key];
if (aVal < bVal) {
return -direction;
} else if (aVal > bVal) {
return direction;
}
return 0;
});
sortItems.set(sorted);
}
const ratingInWords = {
0: "Not Reviewed",
1: "Appalling",
2: "Horrible",
3: "Very Bad",
4: "Bad",
5: "Average",
6: "Fine",
7: "Good",
8: "Very Good",
9: "Great",
10: "Masterpiece",
}
malAnime.subscribe((value) => currentMalAnime = value)
simklAnime.subscribe((value) => currentSimklAnime = value)
submitting.subscribe((value) => isSubmitting = value)
const title = currentAniListAnime.data.MediaList.media.title.english !== "" ?
currentAniListAnime.data.MediaList.media.title.english :
currentAniListAnime.data.MediaList.media.title.romaji
const statusOptions: StatusOptions = [
{id: 0, aniList: "CURRENT", mal: "watching", simkl: "watching"},
{id: 1, aniList: "PLANNING", mal: "plan_to_watch", simkl: "plantowatch"},
{id: 2, aniList: "COMPLETED", mal: "completed", simkl: "completed"},
{id: 3, aniList: "DROPPED", mal: "dropped", simkl: "dropped"},
{id: 4, aniList: "PAUSED", mal: "on_hold", simkl: "hold"},
{id: 5, aniList: "REPEATING", mal: "rewatching", simkl: "watching"}
]
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 = []
let config = {
readOnly: false,
countStars: 5,
range: {
min: 0,
max: 5,
step: 0.5
},
score: currentAniListAnime.data.MediaList.score / 2,
showScore: false,
name: "rating",
scoreFormat: function(){ return `(${this.score.toFixed(0)}/${this.countStars})` },
starConfig: {
size: 32,
fillColor: '#F9ED4F',
strokeColor: "#e2c714",
unfilledColor: '#FFF',
strokeUnfilledColor: '#000'
}
}
let values = {
if (isAniListLoggedIn) tableItems.push({
id: currentAniListAnime.data.MediaList.id,
service: "AniList",
progress: currentAniListAnime.data.MediaList.progress,
status: startingAnilistStatusOption,
startedAt: {
year: currentAniListAnime.data.MediaList.startedAt.year,
month: currentAniListAnime.data.MediaList.startedAt.month,
day: currentAniListAnime.data.MediaList.startedAt.day
},
completedAt: {
year: currentAniListAnime.data.MediaList.completedAt.year,
month: currentAniListAnime.data.MediaList.completedAt.month,
day: currentAniListAnime.data.MediaList.completedAt.day
},
repeat: currentAniListAnime.data.MediaList.repeat,
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
}
let startedAtDate: string
let completedAtDate: string
const changeRating = (e: any) => {
config.score = e.target.valueAsNumber
values.score = e.target.valueAsNumber * 2
}
})
if (values.startedAt.year > 0) {
let startedAtISODate = new Date(values.startedAt.year, values.startedAt.month - 1, values.startedAt.day)
let startedAtMoment = moment(startedAtISODate)
startedAtDate = startedAtMoment.format('YYYY-MM-DD')
}
if (isMalLoggedIn) tableItems.push({
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
})
const transformStartedAtDate = (e: any) => {
const re = /^([0-9]{4})-([0-9]{2})-([0-9]{2})/
const date = re.exec(e.target.value)
values.startedAt.year = Number(date[1])
values.startedAt.month = Number(date[2])
values.startedAt.day = Number(date[3])
}
if (isSimklLoggedIn && Object.keys(currentSimklAnime).length > 0) tableItems.push({
id: currentSimklAnime.show.ids.simkl,
service: "Simkl",
progress: currentSimklAnime.watched_episodes_count,
status: currentSimklAnime.status,
startedAt: "",
completedAt: "",
score: currentSimklAnime.user_rating,
repeat: 0,
notes: ""
})
if (values.completedAt.year > 0) {
let completedAtISODate = new Date(values.completedAt.year, values.completedAt.month - 1, values.completedAt.day)
let completedAtMoment = moment(completedAtISODate)
completedAtDate = completedAtMoment.format('YYYY-MM-DD')
}
const transformCompletedAtDate = (e: any) => {
const re = /^([0-9]{4})-([0-9]{2})-([0-9]{2})/
const date = re.exec(e.target.value)
values.completedAt.year = Number(date[1])
values.completedAt.month = Number(date[2])
values.completedAt.day = Number(date[3])
}
const submitData = async () => {
const handleSubmit = async (e: any) => {
submitting.set(true)
let body: AniListUpdateVariables = {
mediaId: currentAniListAnime.data.MediaList.mediaId,
progress: values.progress,
status: values.status.aniList,
score: values.score,
repeat: values.repeat,
notes: values.notes,
startedAt: {
year: values.startedAt.year,
month: values.startedAt.month,
day: values.startedAt.day
let submitData: {
rating: number,
episodes: number,
status: StatusOption,
startedAt: string,
completedAt: string,
repeat: number,
notes: string,
} = {
rating: 0,
episodes: 0,
status: {
id: 0,
aniList: "",
mal: "",
simkl: "",
},
completedAt: {
year: values.completedAt.year,
month: values.completedAt.month,
day: values.completedAt.day
}
startedAt: "",
completedAt: "",
repeat: 0,
notes: "",
}
const formData = new FormData(e.target)
for (let field of formData) {
const [key, value] = field
if (key === "rating") {
submitData.rating = (Number(value) * 2)
continue
}
if (key === "episodes") {
submitData.episodes = Number(value)
continue
}
if (key === "repeat") {
submitData.repeat = Number(value)
continue
}
if (key === "status") {
submitData.status = startingAnilistStatusOption
continue
}
submitData[key] = value
}
await AniListUpdateEntry(body).then((value) => {
aniListAnime.update(anime => {
anime.data.MediaList.status = value.data.SaveMediaListEntry.status
anime.data.MediaList.progress = value.data.SaveMediaListEntry.progress
anime.data.MediaList.repeat = value.data.SaveMediaListEntry.repeat
anime.data.MediaList.score = value.data.SaveMediaListEntry.score
anime.data.MediaList.startedAt.day = value.data.SaveMediaListEntry.startedAt.day
anime.data.MediaList.startedAt.month = value.data.SaveMediaListEntry.startedAt.month
anime.data.MediaList.startedAt.year = value.data.SaveMediaListEntry.startedAt.year
if (value.data.SaveMediaListEntry.notes === null) {
anime.data.MediaList.notes = ""
} else {
anime.data.MediaList.notes = value.data.SaveMediaListEntry.notes
}
if (value.data.SaveMediaListEntry.completedAt.year === null) {
anime.data.MediaList.completedAt.year = 0
} else {
anime.data.MediaList.completedAt.year = value.data.SaveMediaListEntry.completedAt.year
}
if (value.data.SaveMediaListEntry.completedAt.month === null) {
anime.data.MediaList.completedAt.month = 0
} else {
anime.data.MediaList.completedAt.month = value.data.SaveMediaListEntry.completedAt.month
}
if (value.data.SaveMediaListEntry.completedAt.day === null) {
anime.data.MediaList.completedAt.day = 0
} else {
anime.data.MediaList.completedAt.day = value.data.SaveMediaListEntry.completedAt.day
}
for (let [index, item] of tableItems.entries()) {
if (item.service === "AniList") {
items.update(value => {
value[index].id = anime.data.MediaList.id
value[index].progress = anime.data.MediaList.progress
value[index].status = anime.data.MediaList.status
value[index].startedAt = `${anime.data.MediaList.startedAt.month}-${anime.data.MediaList.startedAt.day}-${anime.data.MediaList.startedAt.year}`
value[index].completedAt = `${anime.data.MediaList.completedAt.month}-${anime.data.MediaList.completedAt.day}-${anime.data.MediaList.completedAt.year}`
value[index].score = anime.data.MediaList.score
value[index].repeat = anime.data.MediaList.repeat
value[index].notes = anime.data.MediaList.notes
return value
})
}
}
return anime
})
})
if (isAniListLoggedIn) {
let body: AniListUpdateVariables = {
mediaId: currentAniListAnime.data.MediaList.mediaId,
progress: submitData.episodes,
status: submitData.status.aniList,
score: submitData.rating,
repeat: submitData.repeat,
notes: submitData.notes,
startedAt: convertDateStringToAniList(submitData.startedAt),
completedAt: convertDateStringToAniList(submitData.completedAt)
}
await AniListUpdateEntry(body).then((value: AniListGetSingleAnime) => {
// 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
aniListAnime.update(newValue => {
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
}
}
})
}
if(malLoggedIn) {
if (malLoggedIn) {
let body: MALUploadStatus = {
status: values.status.mal,
is_rewatching: false,
score: values.score,
num_watched_episodes: values.progress,
num_times_rewatched: values.repeat,
comments: values.notes
status: submitData.status.mal,
is_rewatching: submitData.repeat > 0,
score: submitData.rating,
num_watched_episodes: submitData.episodes,
num_times_rewatched: submitData.repeat,
comments: submitData.notes
}
await MyAnimeListUpdate(currentMalAnime, body).then((malAnimeReturn: MyListStatus) => {
currentMalAnime.my_list_status.status = malAnimeReturn.status
currentMalAnime.my_list_status.is_rewatching = malAnimeReturn.is_rewatching
currentMalAnime.my_list_status.score = malAnimeReturn.score
currentMalAnime.my_list_status.num_episodes_watched = malAnimeReturn.num_episodes_watched
currentMalAnime.my_list_status.num_times_rewatched = malAnimeReturn.num_times_rewatched
currentMalAnime.my_list_status.comments = malAnimeReturn.comments
for (let [index, item] of tableItems.entries()) {
if (item.service === "MyAnimeList") {
items.update(value => {
value[index].id = currentMalAnime.id
value[index].progress = malAnimeReturn.num_episodes_watched
value[index].status = malAnimeReturn.status
value[index].startedAt = malAnimeReturn.start_date
value[index].completedAt = malAnimeReturn.finish_date
value[index].score = malAnimeReturn.score
value[index].repeat = malAnimeReturn.num_times_rewatched
value[index].notes = malAnimeReturn.comments
return value
})
await MyAnimeListUpdate(currentMalAnime, body).then((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.score = malAnimeReturn.score
value.my_list_status.num_episodes_watched = malAnimeReturn.num_episodes_watched
value.my_list_status.num_times_rewatched = malAnimeReturn.num_times_rewatched
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
}
}
})
}
if (simklLoggedIn) {
if (currentSimklAnime.watched_episodes_count !== values.progress) {
await SimklSyncEpisodes(currentSimklAnime, values.progress).then((simklAnimeReturn) => {
simklAnime.set(simklAnimeReturn)
for (let [index, item] of tableItems.entries()) {
if (item.service === "Simkl") {
items.update(value => {
value[index].progress = simklAnimeReturn.watched_episodes_count
return value
})
if (currentSimklAnime.watched_episodes_count !== submitData.episodes) {
await SimklSyncEpisodes(currentSimklAnime, submitData.episodes).then(value => {
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 !== values.score) {
await SimklSyncRating(currentSimklAnime, values.score).then((simklAnimeReturn) => {
simklAnime.set(simklAnimeReturn)
for (let [index, item] of tableItems.entries()) {
if (item.service === "Simkl") {
items.update(value => {
value[index].score = simklAnimeReturn.user_rating
return value
})
}
}
if (currentSimklAnime.user_rating !== submitData.rating) {
await SimklSyncRating(currentSimklAnime, submitData.rating).then(value => {
simklAnime.update(newValue => {
newValue = value
return newValue
})
})
}
if (currentSimklAnime.status !== values.status.simkl) {
await SimklSyncStatus(currentSimklAnime, values.status.simkl).then((simklAnimeReturn) => {
simklAnime.set(simklAnimeReturn)
for (let [index, item] of tableItems.entries()) {
if (item.service === "Simkl") {
items.update(value => {
value[index].status = simklAnimeReturn.status
return value
})
}
}
if (currentSimklAnime.status !== submitData.status.simkl) {
await SimklSyncStatus(currentSimklAnime, submitData.status.simkl).then(value => {
simklAnime.update(newValue => {
newValue = value
return newValue
})
})
}
}
submitting.set(false)
isSubmitSuccess = true
setTimeout(() => isSubmitSuccess = false, 2000)
}
submitting.set(false)
submitSuccess.set(true)
setTimeout(() => submitSuccess.set(false), 2000)
}
</script>
<div class="container py-10">
<form on:submit|preventDefault={handleSubmit} class="container py-10">
<div class="grid grid-cols-1 md:grid-cols-10 grid-flow-col gap-4">
<div class="md:col-span-2 space-y-3">
<img class="rounded-lg" src={currentAniListAnime.data.MediaList.media.coverImage.large} alt="{title} Cover Image">
<StarRatting bind:config on:change={changeRating}/>
<p>Rating: {config.score * 2}</p>
<p>{ratingInWords[config.score * 2]}</p>
<img class="rounded-lg" src={currentAniListAnime.data.MediaList.media.coverImage.large}
alt="{title} Cover Image">
<Rating bind:score={currentAniListAnime.data.MediaList.score}/>
</div>
<div class="md:col-span-8 ">
<div class="flex flex-col md:flex-row md:pl-10 md:pr-10 pt-5 pb-5 justify-center md:gap-x-24 lg:gap-x-56">
<div>
<label for="episodes" class="text-left block mb-2 text-sm font-medium text-gray-900 dark:text-white">Episode
<label for="episodes"
class="text-left block mb-2 text-sm font-medium text-gray-900 dark:text-white">Episode
Progress</label>
<input
type="number"
@ -428,11 +284,11 @@
min="0"
max="{currentAniListAnime.data.MediaList.media.episodes}"
id="episodes"
class="bg-gray-50 border {values.progress < 0 || values.progress > currentAniListAnime.data.MediaList.media.episodes ?
class="bg-gray-50 border {currentAniListAnime.data.MediaList.progress < 0 || currentAniListAnime.data.MediaList.progress > currentAniListAnime.data.MediaList.media.episodes ?
'border-red-300 dark:border-red-500 border-[2px] text-rose-500 dark:text-rose-300 focus:ring-red-500 focus:border-red-500 dark:focus:ring-red-500 dark:focus:border-red-500' :
'border-gray-300 dark:border-gray-500 text-gray-900 dark:text-white focus:ring-blue-500 focus:border-blue-500 dark:focus:ring-blue-500 dark:focus:border-blue-500'
} text-sm rounded-lg block w-24 p-2.5 dark:bg-gray-600 dark:placeholder-gray-400"
bind:value={values.progress}
bind:value={currentAniListAnime.data.MediaList.progress}
required>
<div>of {currentAniListAnime.data.MediaList.media.episodes}</div>
</div>
@ -441,11 +297,11 @@
<div>
<label for="status"
class="text-left block mb-2 text-sm font-medium text-gray-900 dark:text-white">Status</label>
<select id="status"
<select id="status" name="status"
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500
focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400
dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
bind:value={values.status}
bind:value={startingAnilistStatusOption}
>
{#each statusOptions as option}
<option value={option}>{option.aniList}</option>
@ -457,7 +313,8 @@
<div>
<label for="startedAt" class="text-left block mb-2 text-sm font-medium text-gray-900 dark:text-white">Date
<label for="startedAt"
class="text-left block mb-2 text-sm font-medium text-gray-900 dark:text-white">Date
Started</label>
<div class="relative max-w-sm">
<div class="absolute inset-y-0 start-0 flex items-center ps-3.5 pointer-events-none">
@ -475,13 +332,13 @@
dark:placeholder-gray-400 dark:text-white"
value={startedAtDate}
placeholder="Date Started"
on:change={transformStartedAtDate}
>
</div>
</div>
<div>
<label for="completedAt" class="text-left block mb-2 text-sm font-medium text-gray-900 dark:text-white">Date
<label for="completedAt"
class="text-left block mb-2 text-sm font-medium text-gray-900 dark:text-white">Date
Completed</label>
<div class="relative max-w-sm">
<div class="absolute inset-y-0 start-0 flex items-center ps-3.5 pointer-events-none">
@ -499,7 +356,6 @@
dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
value={completedAtDate}
placeholder="Date Completed"
on:change={transformCompletedAtDate}
>
</div>
</div>
@ -511,11 +367,11 @@
name="repeat"
min="0"
id="repeat"
class="bg-gray-50 border {values.repeat < 0 ?
class="bg-gray-50 border {currentAniListAnime.data.MediaList.repeat < 0 ?
'border-red-300 dark:border-red-500 border-[2px] text-rose-500 dark:text-rose-300 focus:ring-red-500 focus:border-red-500 dark:focus:ring-red-500 dark:focus:border-red-500' :
'border-gray-300 dark:border-gray-500 text-gray-900 dark:text-white focus:ring-blue-500 focus:border-blue-500 dark:focus:ring-blue-500 dark:focus:border-blue-500'
} text-sm rounded-lg block w-24 p-2.5 dark:bg-gray-600 dark:placeholder-gray-400 dark:text-white"
bind:value={values.repeat}
bind:value={currentAniListAnime.data.MediaList.repeat}
required>
</div>
</div>
@ -523,63 +379,40 @@
<div class="w-full">
<label for="notes" class="text-left block mb-2 text-sm font-medium text-gray-900 dark:text-white">Your
notes</label>
<textarea id="notes" rows="3"
<textarea id="notes" rows="3" name="notes"
class="block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
placeholder="Write your thoughts here..."
bind:value={values.notes}></textarea>
bind:value={currentAniListAnime.data.MediaList.notes}></textarea>
</div>
</div>
</div>
</div>
<div id="external-data">
<div id="anilist-data" 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 group">
<div id="anilist-data"
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 group">
<h2 class="text-left mb-1 text-base font-semibold text-gray-900 dark:text-white">AniList</h2>
</div>
</div>
<Table hoverable={true}>
<TableHead>
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('id')}>ID</TableHeadCell>
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('service')}>Service</TableHeadCell>
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('progress')}>Episode Progress</TableHeadCell>
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('status')}>Status</TableHeadCell>
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('startedAt')}>Date Started</TableHeadCell>
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('completedAt')}>Date Completed</TableHeadCell>
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('score')}>Rating</TableHeadCell>
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('repeat')}>Rewatches</TableHeadCell>
<TableHeadCell>Notes</TableHeadCell>
</TableHead>
<TableBody tableBodyClass="divide-y">
{#each $sortItems as item}
<TableBodyRow>
<TableBodyCell class="overflow-x-auto">{item.id}</TableBodyCell>
<TableBodyCell class="overflow-x-auto">{item.service}</TableBodyCell>
<TableBodyCell class="overflow-x-auto">{item.progress}</TableBodyCell>
<TableBodyCell class="overflow-x-auto">{item.status}</TableBodyCell>
<TableBodyCell class="overflow-x-auto">{item.startedAt}</TableBodyCell>
<TableBodyCell class="overflow-x-auto">{item.completedAt}</TableBodyCell>
<TableBodyCell class="overflow-x-auto">{item.score}</TableBodyCell>
<TableBodyCell class="overflow-x-auto">{item.repeat}</TableBodyCell>
<TableBodyCell class="overflow-x-auto">{item.notes}</TableBodyCell>
</TableBodyRow>
{/each}
</TableBody>
</Table>
<AnimeTable items={tableItems}/>
<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">
<Button disabled={isSubmitting}
id="sync-button"
class="text-white bg-blue-700 {isSubmitSuccess ?
class="text-white bg-blue-700 {$submitSuccess ?
'dark:bg-green-600 hover:bg-green-800 dark:hover:bg-green-700 focus:ring-4 focus:ring-green-300 dark:focus:ring-green-800' :
'dark:bg-blue-600 hover:bg-blue-800 dark:hover:bg-blue-700 focus:ring-4 focus:ring-blue-300 dark:focus:ring-blue-800'
} font-medium
rounded-lg text-sm px-5 py-2.5 me-2 mb-2 focus:outline-none"
on:click={submitData}>
<svg id="submit-loader" aria-hidden="true" role="status" class="{isSubmitting ? 'inline': 'hidden'} w-4 h-4 me-3 text-white animate-spin" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="#E5E7EB"/>
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentColor"/>
type="submit">
<svg id="submit-loader" aria-hidden="true" role="status"
class="{isSubmitting ? 'inline': 'hidden'} w-4 h-4 me-3 text-white animate-spin"
viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="#E5E7EB"/>
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentColor"/>
</svg>
Sync Changes
</Button>
@ -599,4 +432,4 @@
</h3>
<p>{@html currentAniListAnime.data.MediaList.media.description}</p>
</div>
</div>
</form>

View File

@ -6,7 +6,7 @@ export function AniListLogin():Promise<void>;
export function AniListSearch(arg1:string):Promise<any>;
export function AniListUpdateEntry(arg1:main.AniListUpdateVariables):Promise<any>;
export function AniListUpdateEntry(arg1:main.AniListUpdateVariables):Promise<main.AniListGetSingleAnime>;
export function CheckIfAniListLoggedIn():Promise<boolean>;
@ -36,7 +36,7 @@ export function LogoutSimkl():Promise<string>;
export function MyAnimeListLogin():Promise<void>;
export function MyAnimeListUpdate(arg1:main.MALAnime,arg2:main.MALUploadStatus):Promise<main.MyListStatus>;
export function MyAnimeListUpdate(arg1:main.MALAnime,arg2:main.MALUploadStatus):Promise<main.MalListStatus>;
export function SimklGetUserWatchlist():Promise<main.SimklWatchList>;

View File

@ -188,7 +188,7 @@ export namespace main {
updated_at: updatedAt;
media_type: mediaType;
status: status;
my_list_status: myListStatus;
my_list_status: MalListStatus;
num_episodes: numEpisodes;
start_season: startSeason;
broadcast: broadcast;
@ -311,6 +311,40 @@ export namespace main {
return a;
}
}
export class MalListStatus {
status: status;
score: score;
num_episodes_watched: numEpisodesWatched;
is_rewatching: isRewatching;
start_date: startDate;
finish_date: finishDate;
priority: priority;
num_times_rewatched: numTimesRewatched;
rewatch_value: rewatchValue;
tags: tags;
comments: comments;
updated_at: updatedAt;
static createFrom(source: any = {}) {
return new MalListStatus(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.status = source["status"];
this.score = source["score"];
this.num_episodes_watched = source["num_episodes_watched"];
this.is_rewatching = source["is_rewatching"];
this.start_date = source["start_date"];
this.finish_date = source["finish_date"];
this.priority = source["priority"];
this.num_times_rewatched = source["num_times_rewatched"];
this.rewatch_value = source["rewatch_value"];
this.tags = source["tags"];
this.comments = source["comments"];
this.updated_at = source["updated_at"];
}
}
export class MediaList {
id: number;
mediaId: number;
@ -425,40 +459,6 @@ export namespace main {
this.is_supporter = source["is_supporter"];
}
}
export class MyListStatus {
status: status;
score: score;
num_episodes_watched: numEpisodesWatched;
is_rewatching: isRewatching;
start_date: startDate;
finish_date: finishDate;
priority: priority;
num_times_rewatched: numTimesRewatched;
rewatch_value: rewatchValue;
tags: tags;
comments: comments;
updated_at: updatedAt;
static createFrom(source: any = {}) {
return new MyListStatus(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.status = source["status"];
this.score = source["score"];
this.num_episodes_watched = source["num_episodes_watched"];
this.is_rewatching = source["is_rewatching"];
this.start_date = source["start_date"];
this.finish_date = source["finish_date"];
this.priority = source["priority"];
this.num_times_rewatched = source["num_times_rewatched"];
this.rewatch_value = source["rewatch_value"];
this.tags = source["tags"];
this.comments = source["comments"];
this.updated_at = source["updated_at"];
}
}
export class SimklAnime {
last_watched_at: last_watched_at;
status: status;