feat: implement dynamic sort parameter for AniList watchlist
Add configurable sort functionality to AniList watchlist system: - Add aniListSort writable store to GlobalVariablesAndHelperFunctions - Update Pagination component to subscribe to and use dynamic sort parameter - Refactor CheckIfAniListLoggedInAndLoadWatchList to use sort from store - Remove hardcoded MediaListSort.UpdatedTimeDesc in favor of configurable sort - Improve code formatting with arrow functions and consistent spacing - Add sort parameter to all GetAniListUserWatchingList calls This allows users to customize their watchlist sorting preference instead of being limited to the default 'updated time descending' sort order.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
aniListLoggedIn,
|
||||
aniListSort,
|
||||
aniListWatchlist,
|
||||
animePerPage,
|
||||
watchListPage,
|
||||
@@ -8,24 +9,21 @@
|
||||
|
||||
import type { AniListCurrentUserWatchList } from "../anilist/types/AniListCurrentUserWatchListType";
|
||||
import { GetAniListUserWatchingList } from "../../wailsjs/go/main/App";
|
||||
import { MediaListSort } from "../anilist/types/AniListTypes";
|
||||
|
||||
let aniListWatchListLoaded: AniListCurrentUserWatchList;
|
||||
let page: number;
|
||||
let perPage: number;
|
||||
let sort: string;
|
||||
|
||||
watchListPage.subscribe((value) => (page = value));
|
||||
animePerPage.subscribe((value) => (perPage = value));
|
||||
aniListWatchlist.subscribe((value) => (aniListWatchListLoaded = value));
|
||||
aniListSort.subscribe((value) => (sort = value));
|
||||
|
||||
const perPageOptions = [10, 20, 50];
|
||||
|
||||
function ChangeWatchListPage(newPage: number) {
|
||||
GetAniListUserWatchingList(
|
||||
newPage,
|
||||
perPage,
|
||||
MediaListSort.UpdatedTimeDesc,
|
||||
).then((result) => {
|
||||
GetAniListUserWatchingList(newPage, perPage, sort).then((result) => {
|
||||
watchListPage.set(newPage);
|
||||
aniListWatchlist.set(result);
|
||||
aniListLoggedIn.set(true);
|
||||
@@ -45,16 +43,14 @@
|
||||
function changeCountPerPage(
|
||||
e: Event & { currentTarget: HTMLSelectElement },
|
||||
): void {
|
||||
GetAniListUserWatchingList(
|
||||
1,
|
||||
Number(e.currentTarget.value),
|
||||
MediaListSort.UpdatedTimeDesc,
|
||||
).then((result) => {
|
||||
animePerPage.set(Number(e.currentTarget.value));
|
||||
watchListPage.set(1);
|
||||
aniListWatchlist.set(result);
|
||||
aniListLoggedIn.set(true);
|
||||
});
|
||||
GetAniListUserWatchingList(1, Number(e.currentTarget.value), sort).then(
|
||||
(result) => {
|
||||
animePerPage.set(Number(e.currentTarget.value));
|
||||
watchListPage.set(1);
|
||||
aniListWatchlist.set(result);
|
||||
aniListLoggedIn.set(true);
|
||||
},
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user