Skip to content

Commit

Permalink
app: use constrolled scroll for now playing view
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed May 10, 2024
1 parent 56eca96 commit 7f59a07
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ let app _idb =
Lwd.map (Lwd.get Player.playstate.playlist) ~f:(function
| None -> Elwd.span [ `P (El.txt' "Nothing playing") ]
| Some playlist ->
Ui_playlist.make ~reset_playlist:P.reset_playlist ~fetch
Ui_playlist.make_now_playing ~reset_playlist:P.reset_playlist ~fetch
(Lwd.pure (Fut.ok playlist)))
in
(*todo: do we need that join ?*)
Expand Down
10 changes: 8 additions & 2 deletions bin/ui_playlist.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ let columns () =
v "Title" "1fr" @@ [ `P (El.txt' "Title") ];
|]

let make ~reset_playlist ~fetch (view : (Db.View.t, 'a) Fut.result Lwd.t) =
let make ~reset_playlist ~fetch ?scroll_target
(view : (Db.View.t, 'a) Fut.result Lwd.t) =
let img_url server_id item_id =
let servers =
(* should this be reactive ? *)
Expand Down Expand Up @@ -81,4 +82,9 @@ let make ~reset_playlist ~fetch (view : (Db.View.t, 'a) Fut.result Lwd.t) =
let render = render view in
{ Table.Virtual.total_items; fetch; render })
in
Table.Virtual.make ~ui_table ~placeholder data_source
Table.Virtual.make ~ui_table ~placeholder ?scroll_target data_source

let make_now_playing ~reset_playlist ~fetch
(view : (Db.View.t, 'a) Fut.result Lwd.t) =
let scroll_target = Lwd.get Player.playstate.current_index in
make ~scroll_target ~reset_playlist ~fetch view

0 comments on commit 7f59a07

Please sign in to comment.