mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-06 18:33:38 +02:00
Try to fix pagination (see #28)
This commit is contained in:
parent
cec483dd82
commit
3ef4841c47
3 changed files with 11 additions and 10 deletions
|
|
@ -6,10 +6,15 @@
|
|||
"Concatenates all responses of one type of library to make paging through
|
||||
it a bit easier."
|
||||
[responses [_ kind]]
|
||||
(->> (filter (fn [[[_ params] _]]
|
||||
(= kind (:type params))) responses)
|
||||
(sort-by (fn [[[_ params] _]] (:offset params)))
|
||||
(mapcat (fn [[_ vals]] (:album vals)))))
|
||||
(let [sorted-albums (->> (filter (fn [[[_ params] _]]
|
||||
(= kind (:type params))) responses)
|
||||
(sort-by (fn [[[_ params] _]] (:offset params)))
|
||||
(map (comp :album val)))]
|
||||
;; NOTE: we concatenate this manually to avoid duplication; we have to do
|
||||
;; this because fetch more than conf/albums-per-page per page, otherwise we
|
||||
;; can't know whether to show a link to the next page
|
||||
(concat (mapcat (partial take conf/albums-per-page) (butlast sorted-albums))
|
||||
(last sorted-albums))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:library/complete
|
||||
|
|
|
|||
|
|
@ -32,10 +32,6 @@
|
|||
(let [num-pages (num-pages items per-page max-pages)
|
||||
first-page? (= current-page 1)
|
||||
last-page? (= current-page num-pages)]
|
||||
(println "range"
|
||||
(count items)
|
||||
"num-pages"
|
||||
num-pages)
|
||||
[:nav.pagination {:role "pagination", :aria-label "pagination"}
|
||||
[:a.pagination-previous (if first-page?
|
||||
{:disabled true}
|
||||
|
|
@ -69,7 +65,7 @@
|
|||
{:keys [scan-status]}]
|
||||
(let [library @(subscribe [:library/complete kind])
|
||||
;; FIXME: vv Views shouldn't do calculations vv
|
||||
visible (->> (drop (* (dec page) conf/albums-per-page) library)
|
||||
visible (->> (drop (* (dec (int page)) conf/albums-per-page) library)
|
||||
(take conf/albums-per-page))
|
||||
url-fn #(url-for ::routes/library {:kind kind} {:page %})
|
||||
pagination [pagination {:current-page (int page)
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@
|
|||
;; page through it faster
|
||||
[:api/request "getAlbumList2" {:type kind
|
||||
:size (* 3 conf/albums-per-page)
|
||||
:offset (* page conf/albums-per-page)}]]
|
||||
:offset (* (dec (int page)) conf/albums-per-page)}]]
|
||||
[:routes/do-navigation [route-id {:kind "recent"} {:page 1}]]))
|
||||
|
||||
(defmethod -route-events ::artist.overview
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue