added ability to update simkl episode count
This commit is contained in:
@ -14,16 +14,23 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import type {SimklAnime} from "./simkl/types/simklTypes";
|
||||
import { get } from 'svelte/store';
|
||||
import {AniListUpdateEntry} from "../wailsjs/go/main/App";
|
||||
import {AniListUpdateEntry, SimklSyncEpisodes} from "../wailsjs/go/main/App";
|
||||
|
||||
const simklWatch = get(simklWatchList);
|
||||
let isAniListLoggedIn: boolean
|
||||
let isSimklLoggedIn: boolean
|
||||
let simklAnimeIndex: number
|
||||
let simklAnime: SimklAnime | undefined = undefined
|
||||
|
||||
aniListLoggedIn.subscribe((value) => isAniListLoggedIn = value)
|
||||
simklLoggedIn.subscribe((value) => isSimklLoggedIn = value)
|
||||
|
||||
const simklAnime: SimklAnime | undefined = simklWatch.anime.filter((x) => Number(x.show.ids.mal) === aniListAnime.data.MediaList.media.idMal)[0]
|
||||
for (let i = 0; i < simklWatch.anime.length; i++) {
|
||||
if (Number(simklWatch.anime[i].show.ids.mal) === aniListAnime.data.MediaList.media.idMal) {
|
||||
simklAnimeIndex = i
|
||||
simklAnime = simklWatch.anime[i]
|
||||
}
|
||||
}
|
||||
|
||||
let items = [];
|
||||
|
||||
@ -204,6 +211,13 @@
|
||||
console.log(value)
|
||||
})
|
||||
|
||||
if (simklLoggedIn && simklAnime.watched_episodes_count !== values.progress) {
|
||||
await SimklSyncEpisodes(simklAnime, values.progress).then(value => {
|
||||
console.log(value)
|
||||
simklAnime.watched_episodes_count = values.progress
|
||||
simklWatch.anime[simklAnimeIndex].watched_episodes_count = values.progress
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
2
frontend/wailsjs/go/main/App.d.ts
vendored
2
frontend/wailsjs/go/main/App.d.ts
vendored
@ -23,3 +23,5 @@ export function GetSimklLoggedInUser():Promise<main.SimklUser>;
|
||||
export function SimklGetUserWatchlist():Promise<main.SimklWatchList>;
|
||||
|
||||
export function SimklLogin():Promise<void>;
|
||||
|
||||
export function SimklSyncEpisodes(arg1:main.Anime,arg2:number):Promise<any>;
|
||||
|
@ -45,3 +45,7 @@ export function SimklGetUserWatchlist() {
|
||||
export function SimklLogin() {
|
||||
return window['go']['main']['App']['SimklLogin']();
|
||||
}
|
||||
|
||||
export function SimklSyncEpisodes(arg1, arg2) {
|
||||
return window['go']['main']['App']['SimklSyncEpisodes'](arg1, arg2);
|
||||
}
|
||||
|
@ -91,6 +91,36 @@ export namespace main {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
export class Anime {
|
||||
last_watched_at: last_watched_at;
|
||||
status: status;
|
||||
user_rating: user_rating;
|
||||
last_watched: last_watched;
|
||||
next_to_watch: next_to_watch;
|
||||
watched_episodes_count: watched_episodes_count;
|
||||
total_episodes_count: total_episodes_count;
|
||||
not_aired_episodes_count: not_aired_episodes_count;
|
||||
show: show;
|
||||
anime_type: anime_type;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new Anime(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.last_watched_at = source["last_watched_at"];
|
||||
this.status = source["status"];
|
||||
this.user_rating = source["user_rating"];
|
||||
this.last_watched = source["last_watched"];
|
||||
this.next_to_watch = source["next_to_watch"];
|
||||
this.watched_episodes_count = source["watched_episodes_count"];
|
||||
this.total_episodes_count = source["total_episodes_count"];
|
||||
this.not_aired_episodes_count = source["not_aired_episodes_count"];
|
||||
this.show = source["show"];
|
||||
this.anime_type = source["anime_type"];
|
||||
}
|
||||
}
|
||||
export class MediaList {
|
||||
id: number;
|
||||
mediaId: number;
|
||||
|
Reference in New Issue
Block a user