From 45f30dcffa20b38cffaec785ad8f3141af89dd47 Mon Sep 17 00:00:00 2001 From: trueChazza Date: Wed, 2 Mar 2022 12:32:57 +1300 Subject: [PATCH] refactor: refactor play buttons --- lib/media_server_web/live/movies_live/show.ex | 5 ----- lib/media_server_web/live/movies_live/show.html.heex | 5 ++--- lib/media_server_web/live/series_live/show.ex | 5 ----- lib/media_server_web/live/series_live/show.html.heex | 5 ++--- test/media_server_web/live/movies_live_test.exs | 2 +- 5 files changed, 5 insertions(+), 17 deletions(-) diff --git a/lib/media_server_web/live/movies_live/show.ex b/lib/media_server_web/live/movies_live/show.ex index 3e552e71..b995d2f3 100644 --- a/lib/media_server_web/live/movies_live/show.ex +++ b/lib/media_server_web/live/movies_live/show.ex @@ -13,9 +13,4 @@ defmodule MediaServerWeb.MoviesLive.Show do |> assign(:movie, movie) } end - - @impl true - def handle_event("play", %{"movie" => id}, socket) do - {:noreply, push_redirect(socket, to: Routes.watch_movie_show_path(socket, :show, id))} - end end diff --git a/lib/media_server_web/live/movies_live/show.html.heex b/lib/media_server_web/live/movies_live/show.html.heex index 34daa65f..a938a641 100644 --- a/lib/media_server_web/live/movies_live/show.html.heex +++ b/lib/media_server_web/live/movies_live/show.html.heex @@ -19,9 +19,8 @@

<%= @movie["year"] %> - <%= @movie["runtime"] %> minutes

- + + <%= live_redirect "Play", id: "play-#{ @movie["id"] }", to: Routes.watch_movie_show_path(@socket, :show, @movie["id"]), class: "ml-3 inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-slate-600 hover:bg-slate-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-slate-500" %>
diff --git a/lib/media_server_web/live/series_live/show.ex b/lib/media_server_web/live/series_live/show.ex index 6855938e..2b73a80f 100644 --- a/lib/media_server_web/live/series_live/show.ex +++ b/lib/media_server_web/live/series_live/show.ex @@ -16,9 +16,4 @@ defmodule MediaServerWeb.SeriesLive.Show do |> assign(:episodes, Episodes.get_all(id)) } end - - @impl true - def handle_event("play", %{"episode" => id}, socket) do - {:noreply, push_redirect(socket, to: Routes.watch_episode_show_path(socket, :show, id))} - end end diff --git a/lib/media_server_web/live/series_live/show.html.heex b/lib/media_server_web/live/series_live/show.html.heex index 5eb0faa0..823cf823 100644 --- a/lib/media_server_web/live/series_live/show.html.heex +++ b/lib/media_server_web/live/series_live/show.html.heex @@ -56,9 +56,8 @@

<%= item["overview"] %>

- + + <%= live_redirect "Play", id: "play-#{ item["id"] }", to: Routes.watch_episode_show_path(@socket, :show, item["id"]), class: "mt-4 inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-slate-600 hover:bg-slate-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-slate-500" %> diff --git a/test/media_server_web/live/movies_live_test.exs b/test/media_server_web/live/movies_live_test.exs index 47d3d781..982d743f 100644 --- a/test/media_server_web/live/movies_live_test.exs +++ b/test/media_server_web/live/movies_live_test.exs @@ -44,6 +44,6 @@ defmodule MediaServerWeb.MoviesLiveTest do {:ok, show_live, _html} = live(conn, Routes.movies_show_path(conn, :show, movie["id"])) - assert show_live |> element("button", "Play") |> render_click() + assert show_live |> element("#play-#{ movie["id"] }", "Play") |> render_click() end end