diff options
author | Miguel Ángel Moreno <mail@migalmoreno.com> | 2024-04-19 16:30:21 +0200 |
---|---|---|
committer | Miguel Ángel Moreno <mail@migalmoreno.com> | 2024-04-19 16:35:55 +0200 |
commit | ac56423d109a895d7bdad465ebab63ed2f7f1731 (patch) | |
tree | 1e95e5f3f83e466f2d1ce49f853315dc363d896a /src | |
parent | c58c950acbdc62a1f526938879a31707252ae05b (diff) |
fix: fix infinite search pagination
Diffstat (limited to 'src')
-rw-r--r-- | src/frontend/tubo/events.cljs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/frontend/tubo/events.cljs b/src/frontend/tubo/events.cljs index 5aecfec..c237b1c 100644 --- a/src/frontend/tubo/events.cljs +++ b/src/frontend/tubo/events.cljs @@ -354,12 +354,16 @@ (rf/reg-event-db ::load-paginated-search-results (fn [db [_ res]] - (-> db - (update-in [:search-results :items] #(apply conj %1 %2) - (:items (js->clj res :keywordize-keys true))) - (assoc-in [:search-results :next-page] - (:next-page (js->clj res :keywordize-keys true))) - (assoc :show-pagination-loading false)))) + (let [search-res (js->clj res :keywordize-keys true)] + (if (empty? (:items search-res)) + (-> db + (assoc-in [:search-results :next-page] nil) + (assoc :show-pagination-loading false)) + (-> db + (update-in [:search-results :items] #(apply conj %1 %2) + (:items search-res)) + (assoc-in [:search-results :next-page] (:next-page search-res)) + (assoc :show-pagination-loading false)))))) (rf/reg-event-fx ::search-pagination |