Skip to content

Commit

Permalink
fix: do not display add new watch on unseen movie
Browse files Browse the repository at this point in the history
  • Loading branch information
believer committed Jan 30, 2025
1 parent 62763c8 commit 5a0916d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
3 changes: 2 additions & 1 deletion components/movie/watched.templ
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type WatchedAt struct {
type WatchedProps struct {
WatchedAt []WatchedAt
IsAdmin bool
IsUnseen bool
InWatchlist bool
ImdbId string
ID string
Expand All @@ -35,7 +36,7 @@ templ addWatch(id string, isUnseen bool) {
}

templ Watched(props WatchedProps) {
@c.SectionWithAction("Watched", len(props.WatchedAt), addWatch(props.ID, len(props.WatchedAt) == 0 && !props.InWatchlist)) {
@c.SectionWithAction("Watched", len(props.WatchedAt), addWatch(props.ID, props.IsUnseen)) {
if len(props.WatchedAt) > 0 {
<ol class="flex flex-col gap-2">
for i, w := range props.WatchedAt {
Expand Down
13 changes: 7 additions & 6 deletions components/movie/watched_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions handlers/movies.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func HandleGetMovieSeenByID(c *fiber.Ctx) error {
return utils.TemplRender(c, movie.Watched(movie.WatchedProps{
WatchedAt: watchedAt,
IsAdmin: isAuth,
IsUnseen: len(watchedAt) == 0,
InWatchlist: len(watchlist) > 0,
ImdbId: imdbId,
ID: id,
Expand Down
6 changes: 5 additions & 1 deletion views/movie.templ
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ templ Movie(props MovieProps) {
}
}
}
<div hx-swap="outerHTML" hx-get={ fmt.Sprintf("/movie/%d/seen?imdbId=%s", props.Movie.ID, props.Movie.ImdbId) } hx-trigger="load"></div>
<div
hx-swap="outerHTML"
hx-get={ fmt.Sprintf("/movie/%d/seen?imdbId=%s", props.Movie.ID, props.Movie.ImdbId) }
hx-trigger="load"
></div>
<div
hx-get={ fmt.Sprintf("/movie/%d/cast", props.Movie.ID) }
hx-trigger="load"
Expand Down
4 changes: 2 additions & 2 deletions views/movie_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5a0916d

Please # to comment.