mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-06 18:33:38 +02:00
Fix warning about children with non-unique keys
This commit is contained in:
parent
2aed57deb4
commit
bd511bbc66
3 changed files with 30 additions and 21 deletions
13
package-lock.json
generated
13
package-lock.json
generated
|
|
@ -1794,7 +1794,8 @@
|
||||||
"ansi-regex": {
|
"ansi-regex": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"aproba": {
|
"aproba": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
|
|
@ -2209,7 +2210,8 @@
|
||||||
"safe-buffer": {
|
"safe-buffer": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"safer-buffer": {
|
"safer-buffer": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
|
|
@ -2265,6 +2267,7 @@
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"ansi-regex": "^2.0.0"
|
"ansi-regex": "^2.0.0"
|
||||||
}
|
}
|
||||||
|
|
@ -2308,12 +2311,14 @@
|
||||||
"wrappy": {
|
"wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"yallist": {
|
"yallist": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -88,12 +88,11 @@
|
||||||
:media-play "Play"
|
:media-play "Play"
|
||||||
:media-pause "Pause"
|
:media-pause "Pause"
|
||||||
:media-step-forward "Next"}]
|
:media-step-forward "Next"}]
|
||||||
(map (fn [[icon-glyph event]]
|
(for [[icon-glyph event] buttons]
|
||||||
^{:key icon-glyph} [:p.control>button.button.is-light
|
^{:key icon-glyph} [:p.control [:button.button.is-light
|
||||||
{:on-click (muted-dispatch [event])
|
{:on-click (muted-dispatch [event])
|
||||||
:title (title icon-glyph)}
|
:title (title icon-glyph)}
|
||||||
[icon icon-glyph]])
|
[icon icon-glyph]]]))])
|
||||||
buttons))])
|
|
||||||
|
|
||||||
(defn- toggle-shuffle [playback-mode]
|
(defn- toggle-shuffle [playback-mode]
|
||||||
(muted-dispatch [:audio-player/set-playback-mode (if (= playback-mode :shuffled)
|
(muted-dispatch [:audio-player/set-playback-mode (if (= playback-mode :shuffled)
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,19 @@
|
||||||
^{:key idx} [:li (when (= params active-item)
|
^{:key idx} [:li (when (= params active-item)
|
||||||
{:class-name "is-active"})
|
{:class-name "is-active"})
|
||||||
[:a {:href (apply url-for route)} label]]))]])
|
[:a {:href (apply url-for route)} label]]))]])
|
||||||
;; this variable determines how many pages before the first known page we should list
|
;; this variable determines how many pages before the first known page we should list
|
||||||
(def page-padding 2)
|
(def page-padding 2)
|
||||||
|
|
||||||
|
(defn pagination-link
|
||||||
|
"One of many numbered links to a page"
|
||||||
|
[current-page page href]
|
||||||
|
(let [current-page? (= page current-page)]
|
||||||
|
[(if current-page?
|
||||||
|
:a.pagination-link.is-current
|
||||||
|
:a.pagination-link)
|
||||||
|
(cond-> {:href href, :aria-label (str "Page " page)}
|
||||||
|
current-page? (assoc :aria-current "page")) page]))
|
||||||
|
|
||||||
(defn pagination
|
(defn pagination
|
||||||
"Builds a pagination, calling `url-fn` for every rendered page link with the
|
"Builds a pagination, calling `url-fn` for every rendered page link with the
|
||||||
page as its argument. When `max-pages` is `nil` an infinite pagination
|
page as its argument. When `max-pages` is `nil` an infinite pagination
|
||||||
|
|
@ -22,11 +32,11 @@
|
||||||
[{:keys [items current-page url-fn]}]
|
[{:keys [items current-page url-fn]}]
|
||||||
;; NOTE: This is currently slightly flawed. We don't have any good way to
|
;; NOTE: This is currently slightly flawed. We don't have any good way to
|
||||||
;; know whether we're on the last possible page so we take the last loaded
|
;; know whether we're on the last possible page so we take the last loaded
|
||||||
;; page instead
|
;; page instead
|
||||||
(let [num-pages (last (keys items))
|
(let [num-pages (last (keys items))
|
||||||
first-page? (= current-page 1)
|
first-page? (= current-page 1)
|
||||||
pages (range (max 1 (- current-page page-padding))
|
pages (range (max 1 (- current-page page-padding))
|
||||||
(min (inc (+ current-page page-padding)) (inc num-pages))) ]
|
(min (inc (+ current-page page-padding)) (inc num-pages)))]
|
||||||
[:nav.pagination.is-centered {:role "pagination", :aria-label "pagination"}
|
[:nav.pagination.is-centered {:role "pagination", :aria-label "pagination"}
|
||||||
;; now we add buttons to progress one page in each direction
|
;; now we add buttons to progress one page in each direction
|
||||||
[:a.pagination-previous (if first-page?
|
[:a.pagination-previous (if first-page?
|
||||||
|
|
@ -37,22 +47,17 @@
|
||||||
[:ul.pagination-list
|
[:ul.pagination-list
|
||||||
;; some indication that there are previous pages
|
;; some indication that there are previous pages
|
||||||
(when (> current-page (+ page-padding 2))
|
(when (> current-page (+ page-padding 2))
|
||||||
[:li>a.pagination-link {:href (url-fn 1), :aria-label "Page 1"} "1"])
|
[:li [pagination-link current-page 1 (url-fn 1)]])
|
||||||
(when (> current-page (+ page-padding 1))
|
(when (> current-page (+ page-padding 1))
|
||||||
[:li>span.pagination-ellipsis "…"])
|
[:li>span.pagination-ellipsis "…"])
|
||||||
;; all pagination links around our current page
|
;; all pagination links around our current page
|
||||||
(for [page pages]
|
(for [page pages]
|
||||||
(let [current-page? (= page current-page)]
|
^{:key page} [:li [pagination-link current-page page (url-fn page)]])
|
||||||
^{:key page} [(cond-> :li>a.pagination-link
|
|
||||||
current-page? (add-classes :is-current))
|
|
||||||
(cond-> {:href (url-fn page), :aria-label (str "Page " page)}
|
|
||||||
current-page? (assoc :aria-current "page")) page]))
|
|
||||||
;; some indication that there are more pages after
|
;; some indication that there are more pages after
|
||||||
(when (< current-page (- num-pages page-padding))
|
(when (< current-page (- num-pages page-padding))
|
||||||
[:li>span.pagination-ellipsis "…"])
|
[:li>span.pagination-ellipsis "…"])
|
||||||
(when (< current-page (- num-pages page-padding))
|
(when (< current-page (- num-pages page-padding))
|
||||||
[:li>a.pagination-link {:href (url-fn num-pages), :aria-label (str "Page " num-pages)} num-pages])]]))
|
[:li [pagination-link current-page num-pages (url-fn num-pages)]])]]))
|
||||||
|
|
||||||
|
|
||||||
(def tab-items [[[::routes/library {:kind "recent"} nil] "Recently played"]
|
(def tab-items [[[::routes/library {:kind "recent"} nil] "Recently played"]
|
||||||
[[::routes/library {:kind "newest"} nil] "Newest additions"]
|
[[::routes/library {:kind "newest"} nil] "Newest additions"]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue