Skip to content

Commit

Permalink
fix: handle when to display first year
Browse files Browse the repository at this point in the history
  • Loading branch information
believer committed Nov 27, 2023
1 parent a04ec34 commit 6537a48
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
5 changes: 3 additions & 2 deletions handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ func HandleFeed(c *fiber.Ctx) error {

if strings.Contains(c.Get("Accept"), "hyperview") {
template := "feed"
shouldUpdate := c.Query("refresh") == "true" || c.Query("reset") == "true"

if page != 1 || c.Query("refresh") == "true" {
if page != 1 || shouldUpdate {
template = "feed_pages"
}

Expand All @@ -44,7 +45,7 @@ func HandleFeed(c *fiber.Ctx) error {
"Page": page + 1,
"CurrentYear": time.Now().Year(),
"LastMovieYear": lastMovieYear,
"Refresh": c.Query("refresh"),
"DisplayYear": c.Query("reset") == "true" || page == 1,
})
}

Expand Down
5 changes: 0 additions & 5 deletions views/feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@
<view style="Body" keyboard-dismiss-mode="interactive">
{{ template "search" . }}
<list style="movieList" id="movies" trigger="refresh" href="/?refresh=true" action="replace-inner" target="movie-items">
<item style="Year__Wrap">
<text style="Year">
{{ .CurrentYear }}
</text>
</item>
{{ template "feed_pages" .}}
</list>
<view style="FAB">
Expand Down
4 changes: 2 additions & 2 deletions views/feed_pages.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
{{ if .SearchQuery}}
<item>
<text style="Body__Text">
<behavior action="replace-inner" href="/?refresh=true" target="movie-items" />
<behavior action="replace-inner" href="/?reset=true" target="movie-items" />
Search results for "{{ .SearchQuery }}". Click to reset.
</text>
</item>
{{ end }}
{{ if .Refresh }}
{{ if .DisplayYear }}
<item style="Year__Wrap">
<text style="Year">
{{ .CurrentYear }}
Expand Down

0 comments on commit 6537a48

Please sign in to comment.