mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-06 18:33:38 +02:00
Spring cleaning
* Remove unused subs * Move cover urls into subscriptios * Check if TODOs and FIXMEs are still up to date
This commit is contained in:
parent
504ab841d5
commit
a175fb3d34
6 changed files with 65 additions and 24 deletions
|
|
@ -1,23 +1,30 @@
|
|||
(ns airsonic-ui.subs
|
||||
(:require [re-frame.core :as re-frame]))
|
||||
(:require [re-frame.core :as re-frame :refer [subscribe]]
|
||||
[airsonic-ui.utils.api :as api]))
|
||||
|
||||
;; can be used to query the user's credentials
|
||||
|
||||
;; FIXME: this is used for cover images and it's quite ugly tbh
|
||||
(re-frame/reg-sub
|
||||
::login
|
||||
::credentials
|
||||
(fn [db _]
|
||||
(select-keys (:credentials db) [:u :p])))
|
||||
(:credentials db)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::user
|
||||
(fn [{:keys [credentials]} [_]]
|
||||
(fn [_ _] [(subscribe [::credentials])])
|
||||
(fn [[credentials] _]
|
||||
{:name (:u credentials)}))
|
||||
|
||||
(defn cover-url
|
||||
"Provides a convenient way for views to get cover images so they don't have
|
||||
to build them themselves and can live a simple and happy life."
|
||||
[[{:keys [server u p]}] [_ song size]]
|
||||
(api/cover-url server {:u u :p p} song size))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::server
|
||||
(fn [db _]
|
||||
(get-in db [:credentials :server])))
|
||||
::cover-url
|
||||
(fn [_ _] [(subscribe [::credentials])])
|
||||
cover-url)
|
||||
|
||||
;; current hashbang
|
||||
|
||||
|
|
@ -43,7 +50,7 @@
|
|||
::is-playing?
|
||||
(fn [query-v _]
|
||||
[(re-frame/subscribe [::currently-playing])])
|
||||
(fn [[currently-playing]]
|
||||
(fn [[currently-playing] _]
|
||||
(let [status (:status currently-playing)]
|
||||
(and (not (:paused? status))
|
||||
(not (:ended? status))))))
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
:max (:duration item)}]])
|
||||
|
||||
(defn playback-controls [is-playing?]
|
||||
;; TODO: Toggle play pause icon based on playback status
|
||||
[:div.field.has-addons
|
||||
(let [buttons [[:media-step-backward ::events/previous-song]
|
||||
[(if is-playing? :media-pause :media-play) ::events/toggle-play-pause]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
[re-frame.core :refer [subscribe]]
|
||||
[reagent.core :as reagent]
|
||||
[airsonic-ui.subs :as subs]
|
||||
[airsonic-ui.utils.api :as api]
|
||||
["@hugojosefson/color-hash" :as ColorHash]))
|
||||
|
||||
(def color-hash (ColorHash.))
|
||||
|
|
@ -20,8 +19,6 @@
|
|||
[(mod (+ h (* h 0.3) 10) 360) s l]]
|
||||
(map #(str "hsl(" (str/join "," %) ")")))))
|
||||
|
||||
;; FIXME: The direct dependency on these subs is a bit ugly
|
||||
|
||||
(defn generate-cover [canvas item]
|
||||
(let [ctx (.getContext canvas "2d")
|
||||
size (.-clientWidth canvas)
|
||||
|
|
@ -57,13 +54,14 @@
|
|||
(defn has-cover? [item]
|
||||
(:coverArt item))
|
||||
|
||||
;; FIXME: The direct dependency on these subs is a bit ugly
|
||||
|
||||
(defn cover
|
||||
[item size]
|
||||
(let [server @(subscribe [::subs/server])
|
||||
login @(subscribe [::subs/login])
|
||||
url (partial api/cover-url server login item)]
|
||||
(let [original @(subscribe [::subs/cover-url item size])
|
||||
retina @(subscribe [::subs/cover-url item (* 2 size)])]
|
||||
[:figure {:class-name (str "image is-" size "x" size)}
|
||||
(if (has-cover? item)
|
||||
[:img {:src (url size)
|
||||
:srcSet (str (url size) ", " (url (* 2 size)) " 2x")}]
|
||||
[:img {:src original
|
||||
:srcSet (str original ", " retina " 2x")}]
|
||||
[missing-cover item size])]))
|
||||
|
|
|
|||
|
|
@ -17,13 +17,11 @@
|
|||
(dispatch [::events/play-songs songs song]))}
|
||||
(:title song)]]))
|
||||
|
||||
;; FIXME: This is very similar to album-listing
|
||||
|
||||
(defn listing [songs]
|
||||
[:table.table.is-striped.is-hoverable.is-fullwidth>tbody
|
||||
(for [[idx song] (map-indexed vector songs)]
|
||||
^{:key idx} [:tr
|
||||
[:td.grow [item songs song]]
|
||||
;; FIXME: Not implemented yet
|
||||
[:td>a {:title "Play next"} [icon :plus]]
|
||||
[:td>a {:title "Play last"} [icon :arrow-thick-right]]])])
|
||||
[:td.grow [item songs song]]
|
||||
;; FIXME: Not implemented yet
|
||||
[:td>a {:title "Play next"} [icon :plus]]
|
||||
[:td>a {:title "Play last"} [icon :arrow-thick-right]]])])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue