Fixed components to reload watchlist
This commit is contained in:
parent
5915bb28b8
commit
908325628f
@ -1,108 +1,23 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
import {
|
||||||
aniListLoggedIn,
|
aniListLoggedIn,
|
||||||
aniListPrimary,
|
|
||||||
aniListUser,
|
|
||||||
aniListWatchlist,
|
|
||||||
animePerPage,
|
|
||||||
malLoggedIn,
|
|
||||||
malPrimary,
|
|
||||||
malUser,
|
|
||||||
malWatchList,
|
|
||||||
simklLoggedIn,
|
|
||||||
simklUser,
|
|
||||||
simklWatchList,
|
|
||||||
watchListPage,
|
|
||||||
simklPrimary,
|
|
||||||
aniListAnime,
|
aniListAnime,
|
||||||
GetAniListSingleItem,
|
GetAniListSingleItem,
|
||||||
} from "./helperComponents/GlobalVariablesAndHelperFunctions.svelte";
|
} from "./helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||||
import {
|
|
||||||
CheckIfAniListLoggedIn,
|
|
||||||
CheckIfMyAnimeListLoggedIn,
|
|
||||||
CheckIfSimklLoggedIn,
|
|
||||||
GetAniListLoggedInUser,
|
|
||||||
GetAniListUserWatchingList,
|
|
||||||
GetMyAnimeList,
|
|
||||||
GetMyAnimeListLoggedInUser,
|
|
||||||
GetSimklLoggedInUser,
|
|
||||||
SimklGetUserWatchlist,
|
|
||||||
} from "../wailsjs/go/main/App";
|
|
||||||
import {MediaListSort} from "./anilist/types/AniListTypes";
|
|
||||||
import {onMount} from "svelte";
|
import {onMount} from "svelte";
|
||||||
import Router from "svelte-spa-router"
|
import Router from "svelte-spa-router"
|
||||||
import Home from "./routes/Home.svelte";
|
import Home from "./routes/Home.svelte";
|
||||||
import {wrap} from "svelte-spa-router/wrap";
|
import {wrap} from "svelte-spa-router/wrap";
|
||||||
import Spinner from "./helperComponents/Spinner.svelte";
|
import Spinner from "./helperComponents/Spinner.svelte";
|
||||||
import Header from "./helperComponents/Header.svelte";
|
import Header from "./helperComponents/Header.svelte";
|
||||||
|
import {CheckIfAniListLoggedInAndLoadWatchList} from "./helperModules/CheckIfAniListLoggedInAndLoadWatchList.svelte";
|
||||||
|
import { CheckIfMALLoggedInAndSetUser } from "./helperModules/CheckIfMyAnimeListLoggedIn.svelte";
|
||||||
let isAniListPrimary: boolean
|
import {CheckIfSimklLoggedInAndSetUser} from "./helperModules/CheckIsSimklLoggedIn.svelte"
|
||||||
let isMalPrimary: boolean
|
|
||||||
let isSimklPrimary: boolean
|
|
||||||
|
|
||||||
aniListPrimary.subscribe((value) => isAniListPrimary = value)
|
|
||||||
malPrimary.subscribe((value) => isMalPrimary = value)
|
|
||||||
simklPrimary.subscribe(value => isSimklPrimary = value)
|
|
||||||
|
|
||||||
|
|
||||||
let page: number
|
|
||||||
let perPage: number
|
|
||||||
watchListPage.subscribe(value => page = value)
|
|
||||||
animePerPage.subscribe(value => perPage = value)
|
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
await CheckIfAniListLoggedIn().then(loggedIn => {
|
await CheckIfAniListLoggedInAndLoadWatchList()
|
||||||
if (loggedIn) {
|
await CheckIfMALLoggedInAndSetUser()
|
||||||
GetAniListLoggedInUser().then(user => {
|
await CheckIfSimklLoggedInAndSetUser()
|
||||||
aniListUser.set(user)
|
|
||||||
if (isAniListPrimary) {
|
|
||||||
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((watchList) => {
|
|
||||||
aniListWatchlist.set(watchList)
|
|
||||||
aniListLoggedIn.set(loggedIn)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
aniListLoggedIn.set(loggedIn)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
await CheckIfMyAnimeListLoggedIn().then(loggedIn => {
|
|
||||||
if (loggedIn) {
|
|
||||||
GetMyAnimeListLoggedInUser().then(user => {
|
|
||||||
malUser.set(user)
|
|
||||||
if (isMalPrimary) {
|
|
||||||
GetMyAnimeList(1000).then(watchList => {
|
|
||||||
malWatchList.set(watchList)
|
|
||||||
malLoggedIn.set(loggedIn)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
malLoggedIn.set(loggedIn)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
await CheckIfSimklLoggedIn().then(loggedIn => {
|
|
||||||
if (loggedIn) {
|
|
||||||
GetSimklLoggedInUser().then(user => {
|
|
||||||
if (Object.keys(user).length === 0) {
|
|
||||||
simklLoggedIn.set(false)
|
|
||||||
} else {
|
|
||||||
simklUser.set(user)
|
|
||||||
if(isSimklPrimary) {
|
|
||||||
SimklGetUserWatchlist().then(result => {
|
|
||||||
simklWatchList.set(result)
|
|
||||||
simklLoggedIn.set(loggedIn)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
simklLoggedIn.set(loggedIn)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import {createTable, Render, Subscribe} from "svelte-headless-table";
|
import {createTable, Render, Subscribe} from "svelte-headless-table";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { addSortBy } from "svelte-headless-table/plugins";
|
import { addSortBy } from "svelte-headless-table/plugins";
|
||||||
import {tableItems} from "./GlobalVariablesAndHelperFunctions.svelte"
|
import {tableItems} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte"
|
||||||
|
|
||||||
//when adding sort here is code { sort: addSortBy() }
|
//when adding sort here is code { sort: addSortBy() }
|
||||||
const table = createTable(tableItems, { sort: addSortBy() })
|
const table = createTable(tableItems, { sort: addSortBy() })
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import {Avatar} from "flowbite-svelte";
|
import {Avatar} from "flowbite-svelte";
|
||||||
import type {AniListUser} from "../anilist/types/AniListTypes";
|
import type {AniListUser} from "../anilist/types/AniListTypes";
|
||||||
import {aniListLoggedIn, aniListUser, malLoggedIn, simklLoggedIn, logoutOfAniList, logoutOfMAL, logoutOfSimkl} from "./GlobalVariablesAndHelperFunctions.svelte"
|
import {aniListLoggedIn, aniListUser, malLoggedIn, simklLoggedIn, logoutOfAniList, logoutOfMAL, logoutOfSimkl} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte"
|
||||||
import * as runtime from "../../wailsjs/runtime";
|
import * as runtime from "../../wailsjs/runtime";
|
||||||
|
|
||||||
let currentAniListUser: AniListUser
|
let currentAniListUser: AniListUser
|
||||||
|
@ -10,13 +10,14 @@
|
|||||||
malUser,
|
malUser,
|
||||||
simklLoggedIn,
|
simklLoggedIn,
|
||||||
simklUser,
|
simklUser,
|
||||||
} from "./GlobalVariablesAndHelperFunctions.svelte"
|
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte"
|
||||||
import type {AniListUser} from "../anilist/types/AniListTypes";
|
import type {AniListUser} from "../anilist/types/AniListTypes";
|
||||||
import type {SimklUser} from "../simkl/types/simklTypes";
|
import type {SimklUser} from "../simkl/types/simklTypes";
|
||||||
import type {MyAnimeListUser} from "../mal/types/MALTypes";
|
import type {MyAnimeListUser} from "../mal/types/MALTypes";
|
||||||
import AvatarMenu from "./AvatarMenu.svelte";
|
import AvatarMenu from "./AvatarMenu.svelte";
|
||||||
import logo from "../assets/images/AniTrackLogo.svg"
|
import logo from "../assets/images/AniTrackLogo.svg"
|
||||||
import {location, pop} from "svelte-spa-router";
|
import {location, pop} from "svelte-spa-router";
|
||||||
|
import {CheckIfAniListLoggedInAndLoadWatchList} from "../helperModules/CheckIfAniListLoggedInAndLoadWatchList.svelte";
|
||||||
|
|
||||||
let isAniListLoggedIn: boolean
|
let isAniListLoggedIn: boolean
|
||||||
let isSimklLoggedIn: boolean
|
let isSimklLoggedIn: boolean
|
||||||
@ -42,7 +43,10 @@
|
|||||||
{#if currentLocation === "/"}
|
{#if currentLocation === "/"}
|
||||||
<a href="/"><img src={logo} class="h-8" alt="AniTrack Logo"/></a>
|
<a href="/"><img src={logo} class="h-8" alt="AniTrack Logo"/></a>
|
||||||
{:else}
|
{:else}
|
||||||
<button on:click={() => pop()}><img src={logo} class="h-8" alt="AniTrack Logo"/></button>
|
<button on:click={async () => {
|
||||||
|
await CheckIfAniListLoggedInAndLoadWatchList()
|
||||||
|
return pop()
|
||||||
|
}}><img src={logo} class="h-8" alt="AniTrack Logo"/></button>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center min-[950px]:order-2 space-x-3 min-[950px]:space-x-0 rtl:space-x-reverse">
|
<div class="flex items-center min-[950px]:order-2 space-x-3 min-[950px]:space-x-0 rtl:space-x-reverse">
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
aniListWatchlist,
|
aniListWatchlist,
|
||||||
animePerPage,
|
animePerPage,
|
||||||
watchListPage,
|
watchListPage,
|
||||||
} from "./GlobalVariablesAndHelperFunctions.svelte";
|
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||||
|
|
||||||
import type {AniListCurrentUserWatchList} from "../anilist/types/AniListCurrentUserWatchListType"
|
import type {AniListCurrentUserWatchList} from "../anilist/types/AniListCurrentUserWatchListType"
|
||||||
import {GetAniListUserWatchingList} from "../../wailsjs/go/main/App";
|
import {GetAniListUserWatchingList} from "../../wailsjs/go/main/App";
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
aniListWatchlist,
|
aniListWatchlist,
|
||||||
GetAniListSingleItem,
|
GetAniListSingleItem,
|
||||||
loading,
|
loading,
|
||||||
} from "./GlobalVariablesAndHelperFunctions.svelte";
|
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||||
import {push} from "svelte-spa-router";
|
import {push} from "svelte-spa-router";
|
||||||
import type {AniListCurrentUserWatchList} from "../anilist/types/AniListCurrentUserWatchListType"
|
import type {AniListCurrentUserWatchList} from "../anilist/types/AniListCurrentUserWatchListType"
|
||||||
import {Rating} from "flowbite-svelte";
|
import {Rating} from "flowbite-svelte";
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
<script lang="ts" context="module">
|
||||||
|
import {CheckIfAniListLoggedIn, GetAniListLoggedInUser, GetAniListUserWatchingList} from "../../wailsjs/go/main/App";
|
||||||
|
import {MediaListSort} from "../anilist/types/AniListTypes";
|
||||||
|
import { aniListUser, watchListPage, animePerPage, aniListPrimary, aniListLoggedIn, aniListWatchlist } from "./GlobalVariablesAndHelperFunctions.svelte"
|
||||||
|
|
||||||
|
let isAniListPrimary: boolean
|
||||||
|
let page: number
|
||||||
|
let perPage: number
|
||||||
|
|
||||||
|
aniListPrimary.subscribe(value => isAniListPrimary = value)
|
||||||
|
watchListPage.subscribe(value => page = value)
|
||||||
|
animePerPage.subscribe(value => perPage = value)
|
||||||
|
|
||||||
|
export const CheckIfAniListLoggedInAndLoadWatchList = async () => {
|
||||||
|
await CheckIfAniListLoggedIn().then(loggedIn => {
|
||||||
|
if (loggedIn) {
|
||||||
|
GetAniListLoggedInUser().then(user => {
|
||||||
|
aniListUser.set(user)
|
||||||
|
if (isAniListPrimary) {
|
||||||
|
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((watchList) => {
|
||||||
|
aniListWatchlist.set(watchList)
|
||||||
|
aniListLoggedIn.set(loggedIn)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
aniListLoggedIn.set(loggedIn)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
25
frontend/src/helperModules/CheckIfMyAnimeListLoggedIn.svelte
Normal file
25
frontend/src/helperModules/CheckIfMyAnimeListLoggedIn.svelte
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<script lang="ts" context="module">
|
||||||
|
import {CheckIfMyAnimeListLoggedIn, GetMyAnimeList, GetMyAnimeListLoggedInUser} from "../../wailsjs/go/main/App";
|
||||||
|
import {malUser, malPrimary, malWatchList, malLoggedIn} from "./GlobalVariablesAndHelperFunctions.svelte"
|
||||||
|
|
||||||
|
let isMalPrimary: boolean
|
||||||
|
malPrimary.subscribe(value => isMalPrimary = value)
|
||||||
|
|
||||||
|
export const CheckIfMALLoggedInAndSetUser = async () => {
|
||||||
|
await CheckIfMyAnimeListLoggedIn().then(loggedIn => {
|
||||||
|
if (loggedIn) {
|
||||||
|
GetMyAnimeListLoggedInUser().then(user => {
|
||||||
|
malUser.set(user)
|
||||||
|
if (isMalPrimary) {
|
||||||
|
GetMyAnimeList(1000).then(watchList => {
|
||||||
|
malWatchList.set(watchList)
|
||||||
|
malLoggedIn.set(loggedIn)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
malLoggedIn.set(loggedIn)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
29
frontend/src/helperModules/CheckIsSimklLoggedIn.svelte
Normal file
29
frontend/src/helperModules/CheckIsSimklLoggedIn.svelte
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<script lang="ts" context="module">
|
||||||
|
import {CheckIfSimklLoggedIn, GetSimklLoggedInUser, SimklGetUserWatchlist} from "../../wailsjs/go/main/App";
|
||||||
|
import { simklLoggedIn, simklUser, simklPrimary, simklWatchList } from "./GlobalVariablesAndHelperFunctions.svelte";
|
||||||
|
|
||||||
|
let isSimklPrimary: boolean
|
||||||
|
simklPrimary.subscribe(value => isSimklPrimary = value)
|
||||||
|
|
||||||
|
export const CheckIfSimklLoggedInAndSetUser = async () => {
|
||||||
|
await CheckIfSimklLoggedIn().then(loggedIn => {
|
||||||
|
if (loggedIn) {
|
||||||
|
GetSimklLoggedInUser().then(user => {
|
||||||
|
if (Object.keys(user).length === 0) {
|
||||||
|
simklLoggedIn.set(false)
|
||||||
|
} else {
|
||||||
|
simklUser.set(user)
|
||||||
|
if (isSimklPrimary) {
|
||||||
|
SimklGetUserWatchlist().then(result => {
|
||||||
|
simklWatchList.set(result)
|
||||||
|
simklLoggedIn.set(loggedIn)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
simklLoggedIn.set(loggedIn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
@ -6,7 +6,7 @@
|
|||||||
malLoggedIn,
|
malLoggedIn,
|
||||||
simklAnime,
|
simklAnime,
|
||||||
simklLoggedIn,
|
simklLoggedIn,
|
||||||
} from "../helperComponents/GlobalVariablesAndHelperFunctions.svelte";
|
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||||
import {pop} from "svelte-spa-router";
|
import {pop} from "svelte-spa-router";
|
||||||
import {Button} from "flowbite-svelte";
|
import {Button} from "flowbite-svelte";
|
||||||
import type {AniListGetSingleAnime} from "../anilist/types/AniListCurrentUserWatchListType";
|
import type {AniListGetSingleAnime} from "../anilist/types/AniListCurrentUserWatchListType";
|
||||||
@ -26,7 +26,8 @@
|
|||||||
SimklSyncRating,
|
SimklSyncRating,
|
||||||
SimklSyncStatus
|
SimklSyncStatus
|
||||||
} from "../../wailsjs/go/main/App";
|
} from "../../wailsjs/go/main/App";
|
||||||
import {AddAnimeServiceToTable} from "../helperComponents/AddAnimeServiceToTable.svelte";
|
import {AddAnimeServiceToTable} from "../helperModules/AddAnimeServiceToTable.svelte";
|
||||||
|
import {CheckIfAniListLoggedInAndLoadWatchList} from "../helperModules/CheckIfAniListLoggedInAndLoadWatchList.svelte";
|
||||||
|
|
||||||
let isAniListLoggedIn: boolean
|
let isAniListLoggedIn: boolean
|
||||||
let isMalLoggedIn: boolean
|
let isMalLoggedIn: boolean
|
||||||
@ -434,7 +435,10 @@
|
|||||||
class="text-gray-900 bg-white border border-gray-300 focus:outline-none hover:bg-gray-100 focus:ring-4
|
class="text-gray-900 bg-white border border-gray-300 focus:outline-none hover:bg-gray-100 focus:ring-4
|
||||||
focus:ring-gray-100 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 dark:bg-gray-800 dark:text-white
|
focus:ring-gray-100 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 dark:bg-gray-800 dark:text-white
|
||||||
dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-600 dark:focus:ring-gray-700"
|
dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-600 dark:focus:ring-gray-700"
|
||||||
on:click={() => pop()}>
|
on:click={async () => {
|
||||||
|
await CheckIfAniListLoggedInAndLoadWatchList()
|
||||||
|
return pop()
|
||||||
|
}}>
|
||||||
Back
|
Back
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
aniListLoggedIn,
|
aniListLoggedIn,
|
||||||
aniListPrimary,
|
aniListPrimary,
|
||||||
loading,
|
loading,
|
||||||
} from "../helperComponents/GlobalVariablesAndHelperFunctions.svelte";
|
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||||
import loader from '../helperFunctions/loader'
|
import loader from '../helperFunctions/loader'
|
||||||
|
|
||||||
let isAniListPrimary: boolean
|
let isAniListPrimary: boolean
|
||||||
|
Loading…
Reference in New Issue
Block a user