made SimklWatchList variable more clear as to which watchlist it is
This commit is contained in:
		@@ -11,7 +11,7 @@ import (
 | 
			
		||||
	"strconv"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var WatchList SimklWatchList
 | 
			
		||||
var SimklWatchList SimklWatchListType
 | 
			
		||||
 | 
			
		||||
func SimklHelper(method string, url string, body interface{}) json.RawMessage {
 | 
			
		||||
	reader, _ := json.Marshal(body)
 | 
			
		||||
@@ -49,7 +49,7 @@ func SimklHelper(method string, url string, body interface{}) json.RawMessage {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *App) SimklGetUserWatchlist() SimklWatchList {
 | 
			
		||||
func (a *App) SimklGetUserWatchlist() SimklWatchListType {
 | 
			
		||||
	method := "GET"
 | 
			
		||||
	url := "https://api.simkl.com/sync/all-items/anime/watching"
 | 
			
		||||
 | 
			
		||||
@@ -68,17 +68,17 @@ func (a *App) SimklGetUserWatchlist() SimklWatchList {
 | 
			
		||||
 | 
			
		||||
	if errCheck.Error != "" {
 | 
			
		||||
		a.LogoutSimkl()
 | 
			
		||||
		return SimklWatchList{}
 | 
			
		||||
		return SimklWatchListType{}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var watchlist SimklWatchList
 | 
			
		||||
	var watchlist SimklWatchListType
 | 
			
		||||
 | 
			
		||||
	err = json.Unmarshal(respBody, &watchlist)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Printf("Failed at unmarshal, %s\n", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	WatchList = watchlist
 | 
			
		||||
	SimklWatchList = watchlist
 | 
			
		||||
 | 
			
		||||
	return watchlist
 | 
			
		||||
}
 | 
			
		||||
@@ -124,9 +124,9 @@ func (a *App) SimklSyncEpisodes(anime SimklAnime, progress int) SimklAnime {
 | 
			
		||||
		log.Printf("Failed at unmarshal, %s\n", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for i, simklAnime := range WatchList.Anime {
 | 
			
		||||
	for i, simklAnime := range SimklWatchList.Anime {
 | 
			
		||||
		if anime.Show.Ids.Simkl == simklAnime.Show.Ids.Simkl {
 | 
			
		||||
			WatchList.Anime[i].WatchedEpisodesCount = progress
 | 
			
		||||
			SimklWatchList.Anime[i].WatchedEpisodesCount = progress
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -179,9 +179,9 @@ func (a *App) SimklSyncRating(anime SimklAnime, rating int) SimklAnime {
 | 
			
		||||
		log.Printf("Failed at unmarshal, %s\n", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for i, simklAnime := range WatchList.Anime {
 | 
			
		||||
	for i, simklAnime := range SimklWatchList.Anime {
 | 
			
		||||
		if anime.Show.Ids.Simkl == simklAnime.Show.Ids.Simkl {
 | 
			
		||||
			WatchList.Anime[i].UserRating = rating
 | 
			
		||||
			SimklWatchList.Anime[i].UserRating = rating
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -219,9 +219,9 @@ func (a *App) SimklSyncStatus(anime SimklAnime, status string) SimklAnime {
 | 
			
		||||
		log.Printf("Failed at unmarshal, %s\n", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for i, simklAnime := range WatchList.Anime {
 | 
			
		||||
	for i, simklAnime := range SimklWatchList.Anime {
 | 
			
		||||
		if anime.Show.Ids.Simkl == simklAnime.Show.Ids.Simkl {
 | 
			
		||||
			WatchList.Anime[i].Status = status
 | 
			
		||||
			SimklWatchList.Anime[i].Status = status
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -233,12 +233,12 @@ func (a *App) SimklSyncStatus(anime SimklAnime, status string) SimklAnime {
 | 
			
		||||
func (a *App) SimklSearch(aniListAnime MediaList) SimklAnime {
 | 
			
		||||
	var result SimklAnime
 | 
			
		||||
 | 
			
		||||
	if reflect.DeepEqual(WatchList, SimklWatchList{}) {
 | 
			
		||||
	if reflect.DeepEqual(SimklWatchList, SimklWatchListType{}) {
 | 
			
		||||
		fmt.Println("Watchlist empty. Calling...")
 | 
			
		||||
		WatchList = a.SimklGetUserWatchlist()
 | 
			
		||||
		SimklWatchList = a.SimklGetUserWatchlist()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, anime := range WatchList.Anime {
 | 
			
		||||
	for _, anime := range SimklWatchList.Anime {
 | 
			
		||||
		id, err := strconv.Atoi(anime.Show.Ids.AniList)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			fmt.Println("AniList ID does not exist on " + anime.Show.Title)
 | 
			
		||||
@@ -268,7 +268,7 @@ func (a *App) SimklSearch(aniListAnime MediaList) SimklAnime {
 | 
			
		||||
			log.Printf("Failed at unmarshal, %s\n", err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, watchListAnime := range WatchList.Anime {
 | 
			
		||||
		for _, watchListAnime := range SimklWatchList.Anime {
 | 
			
		||||
			id := watchListAnime.Show.Ids.Simkl
 | 
			
		||||
			if id == anime[0].Ids.Simkl {
 | 
			
		||||
				result = watchListAnime
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ type SimklUser struct {
 | 
			
		||||
	} `json:"connections" ts_type:"connections"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type SimklWatchList struct {
 | 
			
		||||
type SimklWatchListType struct {
 | 
			
		||||
	Anime []SimklAnime `json:"anime" ts_type:"anime"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user