added MAL Login

This commit is contained in:
2024-08-13 18:54:27 -04:00
parent 43a054ac92
commit fa3304db92
14 changed files with 459 additions and 22 deletions

View File

@ -4,6 +4,8 @@
anilistModal,
aniListPrimary,
aniListUser,
malUser,
malLoggedIn,
aniListWatchlist,
GetAniListSingleItemAndOpenModal,
simklLoggedIn,
@ -14,10 +16,12 @@
import {
CheckIfAniListLoggedIn,
CheckIfSimklLoggedIn,
CheckIfMyAnimeListLoggedIn,
GetAniListLoggedInUser,
GetAniListUserWatchingList,
GetSimklLoggedInUser,
SimklGetUserWatchlist,
GetMyAnimeListLoggedInUser,
} from "../wailsjs/go/main/App";
import {MediaListSort} from "./anilist/types/AniListTypes";
import type {AniListCurrentUserWatchList} from "./anilist/types/AniListCurrentUserWatchListType"
@ -58,6 +62,15 @@
}
})
await CheckIfMyAnimeListLoggedIn().then(result => {
if (result) {
GetMyAnimeListLoggedInUser().then(result => {
malUser.set(result)
malLoggedIn.set(result)
})
}
})
await CheckIfSimklLoggedIn().then(result => {
if (result) {
GetSimklLoggedInUser().then(result => {
@ -85,7 +98,7 @@
<main>
{#if isAniListLoggedIn}
<div class="mx-auto max-w-2xl p-4 sm:p-6 lg:max-w-7xl lg:px-8">
<h1 class="text-left text-xl font-bold mb-4">Your WatchList</h1>
<h1 class="text-left text-xl font-bold mb-4">Your AniList WatchList</h1>
<div class="mb-8">
<nav aria-label="Page navigation example">

View File

@ -1,7 +1,7 @@
<script lang="ts" context="module">
import {
GetAniListItem,
GetAniListLoggedInUser,
GetAniListLoggedInUser, GetMyAnimeListLoggedInUser,
GetSimklLoggedInUser
} from "../wailsjs/go/main/App";
import type {
@ -11,16 +11,19 @@
import {writable} from 'svelte/store'
import type {SimklUser, SimklWatchList} from "./simkl/types/simklTypes";
import {type AniListUser} from "./anilist/types/AniListTypes";
import type {MyAnimeListUser} from "./mal/types/MALTypes";
export let aniListAnime: AniListGetSingleAnime
export let title = writable("")
export let anilistModal = writable(false);
export let aniListLoggedIn = writable(false)
export let simklLoggedIn = writable(false)
export let malLoggedIn = writable(false)
export let simklWatchList = writable({} as SimklWatchList)
export let aniListPrimary = writable(true)
export let simklUser = writable({} as SimklUser)
export let aniListUser = writable({} as AniListUser)
export let malUser = writable({} as MyAnimeListUser)
export let aniListWatchlist = writable({} as AniListCurrentUserWatchList)
export function GetAniListSingleItemAndOpenModal(aniId: number, login: boolean): void {
@ -35,15 +38,22 @@
export function loginToSimkl(): void {
GetSimklLoggedInUser().then(result => {
simklUser = result
simklUser.set(result)
simklLoggedIn.set(true)
})
}
export function loginToAniList(): void {
GetAniListLoggedInUser().then(result => {
aniListUser = result
aniListUser.set(result)
aniListLoggedIn.set(true)
})
}
export function loginToMAL(): void {
GetMyAnimeListLoggedInUser().then(result => {
malUser.set(result)
malLoggedIn.set(true)
})
}
</script>

View File

@ -5,23 +5,32 @@
import {
aniListLoggedIn,
simklLoggedIn,
malLoggedIn,
loginToSimkl,
loginToAniList,
loginToMAL,
aniListUser,
simklUser
simklUser,
malUser
} from "./GlobalVariablesAndHelperFunctions.svelte"
import type {AniListUser} from "./anilist/types/AniListTypes";
import type {SimklUser} from "./simkl/types/simklTypes";
import type {MyAnimeListUser} from "./mal/types/MALTypes";
let isAniListLoggedIn: boolean
let isSimklLoggedIn: boolean
let isMALLoggedIn: boolean
let currentAniListUser: AniListUser
let currentSimklUser: SimklUser
let currentMALUser: MyAnimeListUser
aniListLoggedIn.subscribe((value) => isAniListLoggedIn = value)
simklLoggedIn.subscribe((value) => isSimklLoggedIn = value)
malLoggedIn.subscribe((value) => isMALLoggedIn = value)
aniListUser.subscribe((value) => currentAniListUser = value)
simklUser.subscribe((value) => currentSimklUser = value)
malUser.subscribe((value) => currentMALUser = value)
</script>
@ -35,14 +44,21 @@
<div class="flex space-x-2 items-center">
<div>
{#if isAniListLoggedIn}
<span class="bg-green-100 text-green-800 text-sm font-medium me-2 px-2.5 py-0.5 rounded dark:bg-green-900 dark:text-green-300 cursor-default">AniList: {currentAniListUser.data.Viewer.name}</span>
<span class="bg-green-100 text-green-800 text-sm font-medium me-2 px-2.5 py-0.5 rounded dark:bg-green-800 dark:text-green-200 cursor-default">AniList: {currentAniListUser.data.Viewer.name}</span>
{:else}
<button on:click={loginToAniList} class="bg-blue-100 hover:bg-blue-200 text-blue-800 text-sm font-medium me-2 px-2.5 py-0.5 rounded dark:bg-gray-700 dark:text-blue-400 border border-blue-400 inline-flex items-center justify-center">AniList</button>
{/if}
</div>
<div>
{#if isMALLoggedIn}
<span class="bg-blue-100 text-blue-800 text-sm font-medium me-2 px-2.5 py-0.5 rounded dark:bg-blue-800 dark:text-blue-200 cursor-default">MAL: {currentMALUser.name}</span>
{:else}
<button on:click={loginToMAL} class="bg-blue-100 hover:bg-blue-200 text-blue-800 text-sm font-medium me-2 px-2.5 py-0.5 rounded dark:bg-gray-700 dark:text-blue-400 border border-blue-400 inline-flex items-center justify-center">MAL</button>
{/if}
</div>
<div>
{#if isSimklLoggedIn}
<span class="bg-indigo-100 text-indigo-800 text-sm font-medium me-2 px-2.5 py-0.5 rounded dark:bg-indigo-900 dark:text-indigo-300 cursor-default">Simkl: {currentSimklUser.user.name}</span>
<span class="bg-indigo-100 text-indigo-800 text-sm font-medium me-2 px-2.5 py-0.5 rounded dark:bg-indigo-800 dark:text-indigo-200 cursor-default">Simkl: {currentSimklUser.user.name}</span>
{:else}
<button on:click={loginToSimkl} class="bg-blue-100 hover:bg-blue-200 text-blue-800 text-sm font-medium me-2 px-2.5 py-0.5 rounded dark:bg-gray-700 dark:text-blue-400 border border-blue-400 inline-flex items-center justify-center">Simkl</button>
{/if}

View File

@ -0,0 +1,31 @@
export interface MyAnimeListUser {
id: number
name: string
picture: string
gender: string
birthday: string
location: string
joinedAt: string
AnimeStatistics: AnimeStatistics
timeZone: string
isSupporter: boolean
}
export interface AnimeStatistics {
numItemsWatching: number
numItemsCompleted: number
numItemsOnHold: number
numItemsDropped: number
numItemsPlanToWatch: number
numItems: number
numDaysWatched: number
numDaysWatching: number
numDaysCompleted: number
numDaysOnHold: number
numDaysDropped: number
numDays: number
numEpisodes: number
numTimesRewatched: number
meanScore: number
}

View File

@ -10,6 +10,8 @@ export function AniListUpdateEntry(arg1:number,arg2:number,arg3:string,arg4:numb
export function CheckIfAniListLoggedIn():Promise<boolean>;
export function CheckIfMyAnimeListLoggedIn():Promise<boolean>;
export function CheckIfSimklLoggedIn():Promise<boolean>;
export function GetAniListItem(arg1:number,arg2:boolean):Promise<main.AniListGetSingleAnime>;
@ -18,8 +20,12 @@ export function GetAniListLoggedInUser():Promise<main.AniListUser>;
export function GetAniListUserWatchingList(arg1:number,arg2:number,arg3:string):Promise<main.AniListCurrentUserWatchList>;
export function GetMyAnimeListLoggedInUser():Promise<main.MyAnimeListUser>;
export function GetSimklLoggedInUser():Promise<main.SimklUser>;
export function MyAnimeListLogin():Promise<void>;
export function SimklGetUserWatchlist():Promise<main.SimklWatchList>;
export function SimklLogin():Promise<void>;

View File

@ -18,6 +18,10 @@ export function CheckIfAniListLoggedIn() {
return window['go']['main']['App']['CheckIfAniListLoggedIn']();
}
export function CheckIfMyAnimeListLoggedIn() {
return window['go']['main']['App']['CheckIfMyAnimeListLoggedIn']();
}
export function CheckIfSimklLoggedIn() {
return window['go']['main']['App']['CheckIfSimklLoggedIn']();
}
@ -34,10 +38,18 @@ export function GetAniListUserWatchingList(arg1, arg2, arg3) {
return window['go']['main']['App']['GetAniListUserWatchingList'](arg1, arg2, arg3);
}
export function GetMyAnimeListLoggedInUser() {
return window['go']['main']['App']['GetMyAnimeListLoggedInUser']();
}
export function GetSimklLoggedInUser() {
return window['go']['main']['App']['GetSimklLoggedInUser']();
}
export function MyAnimeListLogin() {
return window['go']['main']['App']['MyAnimeListLogin']();
}
export function SimklGetUserWatchlist() {
return window['go']['main']['App']['SimklGetUserWatchlist']();
}

View File

@ -177,6 +177,64 @@ export namespace main {
return a;
}
}
export class MyAnimeListUser {
id: id;
name: name;
picture: picture;
gender: gender;
birthday: birthday;
location: location;
joined_at: joinedAt;
num_items_watching: numItemsWatching;
num_items_completed: numItemsCompleted;
num_items_on_hold: numItemsOnHold;
num_items_dropped: numItemsDropped;
num_items_plan_to_watch: numItemsPlanToWatch;
num_items: numItems;
num_days_watched: numDaysWatched;
num_days_watching: numDaysWatching;
num_days_completed: numDaysCompleted;
num_days_on_hold: numDaysOnHold;
num_days_dropped: numDaysDropped;
num_days: numDays;
num_episodes: numEpisodes;
num_times_rewatched: numTimesRewatched;
mean_score: meanScore;
time_zone: timeZone;
is_supporter: isSupporter;
static createFrom(source: any = {}) {
return new MyAnimeListUser(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.id = source["id"];
this.name = source["name"];
this.picture = source["picture"];
this.gender = source["gender"];
this.birthday = source["birthday"];
this.location = source["location"];
this.joined_at = source["joined_at"];
this.num_items_watching = source["num_items_watching"];
this.num_items_completed = source["num_items_completed"];
this.num_items_on_hold = source["num_items_on_hold"];
this.num_items_dropped = source["num_items_dropped"];
this.num_items_plan_to_watch = source["num_items_plan_to_watch"];
this.num_items = source["num_items"];
this.num_days_watched = source["num_days_watched"];
this.num_days_watching = source["num_days_watching"];
this.num_days_completed = source["num_days_completed"];
this.num_days_on_hold = source["num_days_on_hold"];
this.num_days_dropped = source["num_days_dropped"];
this.num_days = source["num_days"];
this.num_episodes = source["num_episodes"];
this.num_times_rewatched = source["num_times_rewatched"];
this.mean_score = source["mean_score"];
this.time_zone = source["time_zone"];
this.is_supporter = source["is_supporter"];
}
}
export class SimklUser {
user: user;
account: account;