Skip to content

Commit

Permalink
fix default video not honoring configured direction
Browse files Browse the repository at this point in the history
  • Loading branch information
breunigs committed May 17, 2024
1 parent 6e41796 commit 96f9f9c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions lib/veloroute_web/live/video_state.ex
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ defmodule VelorouteWeb.Live.VideoState do
set_start(new_state, near)

true ->
Logger.debug("no position information, not changing")
Logger.debug("no position information, not changing #{near_dbg}")
new_state
end

Expand Down Expand Up @@ -440,7 +440,10 @@ defmodule VelorouteWeb.Live.VideoState do

defmemop new() do
sett = Settings.start_image()
default_tracks = Article.List.find_exact(sett.article_id).tracks()

default_tracks =
Article.List.find_exact(sett.article_id).tracks()
|> Enum.filter(&(&1.direction == sett.direction))

%__MODULE__{
forward_track: nil,
Expand Down
8 changes: 4 additions & 4 deletions test/veloroute_web/live/navigation_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ defmodule VelorouteWeb.LiveNavigationTest do
|> render_click() =~ "Artikel zu Veloroute 7"
end

test "initial render sets video", %{conn: conn} do
{:ok, _view, html} = live(conn, "/")
refute html =~ ~s|data-video-hash=""|
refute html =~ ~s|data-video-start="0"|
test "initial render selects video near the start", %{conn: conn} do
{:ok, view, _html} = live(conn, "/")
# i.e. from 0 ms to 19999ms
assert view |> element("progress") |> render() =~ ~r{value="1?\d?\d?\d?\d"}
end

test "initial render starts video at 0 even on articles", %{conn: conn} do
Expand Down

0 comments on commit 96f9f9c

Please sign in to comment.