From 065ac0950f9385ce3a98cc97d9e47ffc5778a72d Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sat, 27 Jul 2024 21:18:03 -0400 Subject: [PATCH] added Not Reviewed so zero does not equal undefined --- AniListFunctions.go | 42 +++++++++++++------ frontend/package.json | 5 ++- frontend/src/ChangeDataDialogue.svelte | 1 + .../GetAniListSingleItemAndOpenModal.svelte | 4 +- frontend/src/Search.svelte | 4 +- frontend/wailsjs/go/main/App.d.ts | 2 +- frontend/wailsjs/go/main/App.js | 4 +- frontend/wailsjs/go/models.ts | 6 +++ 8 files changed, 47 insertions(+), 21 deletions(-) diff --git a/AniListFunctions.go b/AniListFunctions.go index 4049023..ccebd86 100644 --- a/AniListFunctions.go +++ b/AniListFunctions.go @@ -35,16 +35,38 @@ func AniListQuery(body interface{}, login bool) (json.RawMessage, string) { return returnedBody, "" } -func (a *App) GetAniListItem(aniId int) AniListGetSingleAnime { +func (a *App) GetAniListItem(aniId int, login bool) AniListGetSingleAnime { var user = a.GetAniListLoggedInUserId() - type Variables struct { - UserId int `json:"userId"` - MediaId int `json:"mediaId"` - ListType string `json:"listType"` + // type Variables struct { + // UserId int `json:"userId"` + // MediaId int `json:"mediaId"` + // ListType string `json:"listType"` + // } + + var neededVariables interface{} + + if login { + neededVariables = struct{ + MediaId int `json:"mediaId"` + UserId int `json:"userId"` + ListType string `json:"listType"` + } { + MediaId: aniId, + UserId: user.Data.Viewer.ID, + ListType: "ANIME", + } + } else { + neededVariables = struct { + MediaId int `json:"mediaId"` + ListType string `json:"listType"` + } { + MediaId: aniId, + ListType: "ANIME", + } } body := struct { Query string `json:"query"` - Variables Variables `json:"variables"` + Variables interface{} `json:"variables"` }{ Query: ` query($userId: Int, $mediaId: Int, $listType: MediaType) { @@ -109,15 +131,11 @@ func (a *App) GetAniListItem(aniId int) AniListGetSingleAnime { } } `, - Variables: Variables{ - MediaId: aniId, - UserId: user.Data.Viewer.ID, - ListType: "ANIME", - }, + Variables: neededVariables, } returnedBody, _ := AniListQuery(body, false) - + var post AniListGetSingleAnime err := json.Unmarshal(returnedBody, &post) if err != nil { diff --git a/frontend/package.json b/frontend/package.json index 49f29a3..b50ab03 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -24,8 +24,9 @@ "vite": "^3.0.7" }, "dependencies": { + "@ernane/svelte-star-rating": "^1.1.7", + "@popperjs/core": "^2.11.8", "flowbite": "^2.4.1", - "flowbite-svelte": "^0.46.15", - "@popperjs/core": "^2.11.8" + "flowbite-svelte": "^0.46.15" } } diff --git a/frontend/src/ChangeDataDialogue.svelte b/frontend/src/ChangeDataDialogue.svelte index d254d21..edabf86 100644 --- a/frontend/src/ChangeDataDialogue.svelte +++ b/frontend/src/ChangeDataDialogue.svelte @@ -4,6 +4,7 @@ import StarRatting from "@ernane/svelte-star-rating" const ratingInWords = { + 0: "Not Reviewed", 1: "Apalling", 2: "Horrible", 3: "Very Bad", diff --git a/frontend/src/GetAniListSingleItemAndOpenModal.svelte b/frontend/src/GetAniListSingleItemAndOpenModal.svelte index c58835a..1b55db8 100644 --- a/frontend/src/GetAniListSingleItemAndOpenModal.svelte +++ b/frontend/src/GetAniListSingleItemAndOpenModal.svelte @@ -7,8 +7,8 @@ export let title = writable("") export let anilistModal = writable(false); - export function GetAniListSingleItemAndOpenModal(aniId: number): void { - GetAniListItem(aniId).then(result => { + export function GetAniListSingleItemAndOpenModal(aniId: number, login: boolean): void { + GetAniListItem(aniId, login).then(result => { anime = result title.set(anime.data.MediaList.media.title.english === "" ? anime.data.MediaList.media.title.romaji : diff --git a/frontend/src/Search.svelte b/frontend/src/Search.svelte index 64c357f..f2a5795 100644 --- a/frontend/src/Search.svelte +++ b/frontend/src/Search.svelte @@ -10,7 +10,7 @@ function runAniListSearch(): void { AniListSearch(aniSearch).then(result => { - console.log(result) + console.log(result.data.Page.media[5]) aniListSearch = result aniListSearchActive = true }) @@ -52,7 +52,7 @@ {#each aniListSearch.data.Page.media as media}