fixed bug where anilist would display a different users stats if show was not in watchlist
This commit is contained in:
parent
9f8014ff00
commit
a24a187c7f
@ -32,7 +32,7 @@ func AniListQuery(body interface{}, login bool) (json.RawMessage, string) {
|
||||
|
||||
returnedBody, err := io.ReadAll(res.Body)
|
||||
|
||||
return returnedBody, ""
|
||||
return returnedBody, res.Status
|
||||
}
|
||||
|
||||
func (a *App) GetAniListItem(aniId int, login bool) AniListGetSingleAnime {
|
||||
@ -138,14 +138,44 @@ func (a *App) GetAniListItem(aniId int, login bool) AniListGetSingleAnime {
|
||||
Variables: neededVariables,
|
||||
}
|
||||
|
||||
returnedBody, _ := AniListQuery(body, login)
|
||||
|
||||
returnedBody, status := AniListQuery(body, login)
|
||||
var post AniListGetSingleAnime
|
||||
|
||||
if status == "404 Not Found" && login == false {
|
||||
return post
|
||||
}
|
||||
|
||||
if status == "404 Not Found" && login {
|
||||
post = a.GetAniListItem(aniId, false)
|
||||
}
|
||||
|
||||
err := json.Unmarshal(returnedBody, &post)
|
||||
if err != nil {
|
||||
log.Printf("Failed at unmarshal, %s\n", err)
|
||||
}
|
||||
|
||||
if login == false {
|
||||
post.Data.MediaList.UserID = user.Data.Viewer.ID
|
||||
post.Data.MediaList.Status = ""
|
||||
post.Data.MediaList.StartedAt.Year = 0
|
||||
post.Data.MediaList.StartedAt.Month = 0
|
||||
post.Data.MediaList.StartedAt.Day = 0
|
||||
post.Data.MediaList.CompletedAt.Year = 0
|
||||
post.Data.MediaList.CompletedAt.Month = 0
|
||||
post.Data.MediaList.CompletedAt.Day = 0
|
||||
post.Data.MediaList.Notes = ""
|
||||
post.Data.MediaList.Progress = 0
|
||||
post.Data.MediaList.Score = 0
|
||||
post.Data.MediaList.Repeat = 0
|
||||
post.Data.MediaList.User.ID = user.Data.Viewer.ID
|
||||
post.Data.MediaList.User.Name = user.Data.Viewer.Name
|
||||
post.Data.MediaList.User.Avatar.Large = user.Data.Viewer.Avatar.Large
|
||||
post.Data.MediaList.User.Avatar.Medium = user.Data.Viewer.Avatar.Medium
|
||||
post.Data.MediaList.User.Statistics.Anime.Count = 0
|
||||
// This provides an empty array and frees up the memory from the garbage collector
|
||||
post.Data.MediaList.User.Statistics.Anime.Statuses = nil
|
||||
}
|
||||
|
||||
return post
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ body:graphql {
|
||||
body:graphql:vars {
|
||||
{
|
||||
"userId": 413504,
|
||||
"mediaId": 1,
|
||||
"mediaId": 168345,
|
||||
"listType": "ANIME"
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ body:graphql {
|
||||
|
||||
body:graphql:vars {
|
||||
{
|
||||
"search": "frieren",
|
||||
"search": "dungeon people",
|
||||
"listType": "ANIME"
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ meta {
|
||||
}
|
||||
|
||||
get {
|
||||
url: https://api.simkl.com/anime/862523?extended=full
|
||||
url: https://api.simkl.com/anime/1579943?extended=full
|
||||
body: none
|
||||
auth: none
|
||||
}
|
||||
|
2
frontend/wailsjs/go/main/App.d.ts
vendored
2
frontend/wailsjs/go/main/App.d.ts
vendored
@ -38,7 +38,7 @@ export function MyAnimeListLogin():Promise<void>;
|
||||
|
||||
export function MyAnimeListUpdate(arg1:main.MALAnime,arg2:main.MALUploadStatus):Promise<main.MalListStatus>;
|
||||
|
||||
export function SimklGetUserWatchlist():Promise<main.SimklWatchList>;
|
||||
export function SimklGetUserWatchlist():Promise<main.SimklWatchListType>;
|
||||
|
||||
export function SimklLogin():Promise<void>;
|
||||
|
||||
|
@ -505,11 +505,11 @@ export namespace main {
|
||||
this.connections = source["connections"];
|
||||
}
|
||||
}
|
||||
export class SimklWatchList {
|
||||
export class SimklWatchListType {
|
||||
anime: anime;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new SimklWatchList(source);
|
||||
return new SimklWatchListType(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
|
Loading…
Reference in New Issue
Block a user