Previous and Next episode number is taken from array
If there is episode "skips" in database now should work with them too.
This commit is contained in:
parent
7d2f93f344
commit
bd65be8ee6
@ -33,11 +33,14 @@ func Get(ctx *aero.Context) string {
|
|||||||
return ctx.Error(http.StatusNotFound, "Anime episodes not found", err)
|
return ctx.Error(http.StatusNotFound, "Anime episodes not found", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
episode := animeEpisodes.Find(episodeNumber)
|
episode, _ := animeEpisodes.Find(episodeNumber)
|
||||||
|
|
||||||
if episode == nil {
|
if episode == nil {
|
||||||
return ctx.Error(http.StatusNotFound, "Anime episode not found", nil)
|
return ctx.Error(http.StatusNotFound, "Anime episode not found", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.HTML(components.AnimeEpisode(anime, episode, user))
|
_, previousIndex := animeEpisodes.Find(episodeNumber - 1)
|
||||||
|
_, nextIndex := animeEpisodes.Find(episodeNumber + 1)
|
||||||
|
|
||||||
|
return ctx.HTML(components.AnimeEpisode(anime, episode, user, previousIndex, nextIndex))
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
component AnimeEpisode(anime *arn.Anime, episode *arn.AnimeEpisode, user *arn.User)
|
component AnimeEpisode(anime *arn.Anime, episode *arn.AnimeEpisode, user *arn.User, previousIndex int, nextIndex int)
|
||||||
h1
|
h1
|
||||||
a(href=anime.Link())= anime.Title.ByUser(user)
|
a(href=anime.Link())= anime.Title.ByUser(user)
|
||||||
|
|
||||||
@ -8,13 +8,13 @@ component AnimeEpisode(anime *arn.Anime, episode *arn.AnimeEpisode, user *arn.Us
|
|||||||
|
|
||||||
h3.episode-view-number= "Episode " + strconv.Itoa(episode.Number)
|
h3.episode-view-number= "Episode " + strconv.Itoa(episode.Number)
|
||||||
|
|
||||||
if episode.Number > anime.Episodes().Items[0].Number
|
//- if (previousIndex != -1)
|
||||||
a.button(href=anime.Link() + "/episode/" + strconv.Itoa(episode.Number - 1))
|
//- a.button(href=anime.Link() + "/episode/" + strconv.Itoa(anime.Episodes().Items[previousIndex].Number))
|
||||||
Icon("chevron-left")
|
//- Icon("chevron-left")
|
||||||
|
|
||||||
if episode.Number < anime.Episodes().Items[len(anime.Episodes().Items) - 1].Number
|
//- if (nextIndex != -1)
|
||||||
a.button(href=anime.Link() + "/episode/" + strconv.Itoa(episode.Number + 1))
|
//- a.button(href=anime.Link() + "/episode/" + strconv.Itoa(anime.Episodes().Items[nextIndex].Number))
|
||||||
Icon("chevron-right")
|
//- Icon("chevron-right")
|
||||||
|
|
||||||
if episode.Title.Japanese != ""
|
if episode.Title.Japanese != ""
|
||||||
.episode-view-title
|
.episode-view-title
|
||||||
|
Loading…
Reference in New Issue
Block a user