mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-06 18:33:38 +02:00
Update views to utilize new playlist, implement play next / play last
This commit is contained in:
parent
4d49b3a3ff
commit
bac22c03a1
3 changed files with 29 additions and 7 deletions
|
|
@ -214,6 +214,16 @@
|
|||
{:db db
|
||||
:audio/play (song-url db prev)})))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::enqueue-next
|
||||
(fn [db [_ song]]
|
||||
(update-in db [:audio :playlist] #(playlist/enqueue-next % song))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::enqueue-last
|
||||
(fn [db [_ song]]
|
||||
(update-in db [:audio :playlist] #(playlist/enqueue-last % song))))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::toggle-play-pause
|
||||
(fn [_ _]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
(ns airsonic-ui.utils.helpers
|
||||
"Assorted helper functions")
|
||||
"Assorted helper functions"
|
||||
(:require [re-frame.core :as rf]))
|
||||
|
||||
(defn find-where
|
||||
"Returns the the first item in `coll` with its index for which `(p song)`
|
||||
|
|
@ -8,3 +9,10 @@
|
|||
(->> (map-indexed vector coll)
|
||||
(reduce (fn [_ [idx song]]
|
||||
(when (p song) (reduced [idx song]))) nil)))
|
||||
|
||||
(defn dispatch
|
||||
"Dispatches a re-frame event while canceling default DOM behavior"
|
||||
[ev]
|
||||
(fn [e]
|
||||
(.preventDefault e)
|
||||
(rf/dispatch ev)))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
(ns airsonic-ui.views.song
|
||||
(:require [re-frame.core :refer [dispatch]]
|
||||
(:require [airsonic-ui.utils.helpers :refer [dispatch]]
|
||||
[airsonic-ui.events :as events]
|
||||
[airsonic-ui.routes :as routes :refer [url-for]]
|
||||
[airsonic-ui.views.icon :refer [icon]]))
|
||||
|
|
@ -12,9 +12,7 @@
|
|||
(:artist song)]
|
||||
" - "
|
||||
[:a
|
||||
{:href "#" :on-click (fn [e]
|
||||
(.preventDefault e)
|
||||
(dispatch [::events/play-songs songs idx]))}
|
||||
{:href "#" :on-click (dispatch [::events/play-songs songs idx])}
|
||||
(:title song)]]))
|
||||
|
||||
(defn listing [songs]
|
||||
|
|
@ -23,5 +21,11 @@
|
|||
^{:key idx} [:tr
|
||||
[:td.grow [item songs song idx]]
|
||||
;; FIXME: Not implemented yet
|
||||
[:td>a {:title "Play next"} [icon :plus]]
|
||||
[:td>a {:title "Play last"} [icon :arrow-thick-right]]])])
|
||||
[:td>a {:title "Play next"
|
||||
:href "#"
|
||||
:on-click (dispatch [::events/enqueue-next song])}
|
||||
[icon :plus]]
|
||||
[:td>a {:title "Play last"
|
||||
:href "#"
|
||||
:on-click (dispatch [::events/enqueue-last song])}
|
||||
[icon :arrow-thick-right]]])])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue