Disable fetch more button while posts are loaded
This commit is contained in:
parent
a152c942ea
commit
fa3e3ad5cb
1 changed files with 4 additions and 18 deletions
|
|
@ -442,7 +442,7 @@
|
|||
[:path.arc {:d "M50,0 A50,50 180 0,1 100,50"}]]))
|
||||
|
||||
(defn posts-section [{:keys [posts]}]
|
||||
(let [{:keys [per-page query total displayed-posts]} posts
|
||||
(let [{:keys [per-page query total displayed-posts loading]} posts
|
||||
n-displayed (count displayed-posts)]
|
||||
[:section.posts
|
||||
[:h2 "Favorites"]
|
||||
|
|
@ -456,28 +456,14 @@
|
|||
" matches")))))]
|
||||
[:section.search-form
|
||||
[search]
|
||||
[loading-indicator (select-keys posts [:loading])]
|
||||
[loading-indicator {:loading loading}]
|
||||
#_(cond (= api-state :loading) " …"
|
||||
(= api-state :error) " API Error!")]
|
||||
[:section.buttons
|
||||
[:button.control-button {:on-click fetch-more-posts!} "⇓ Fetch more"]
|
||||
[:button.control-button {:on-click fetch-more-posts! :disabled (boolean (seq loading))} "⇓ Fetch more"]
|
||||
[:button.control-button {:on-click disconnect-account!} "▤ Disconnect account"]]]
|
||||
[:ul.results (map-indexed (fn [idx p]
|
||||
^{:key idx} [:li.result [post {:post p}]]) displayed-posts)]
|
||||
#_[:div.load-buttons
|
||||
[:button
|
||||
{:on-click (fn [_]
|
||||
(let [num-posts (count posts)]
|
||||
(fetch-posts! {:continue? (fn [response]
|
||||
(and (seq (:body response))
|
||||
(< (count (:favorites @state)) (+ num-posts 1000))))})))}
|
||||
"Load more"]
|
||||
" "
|
||||
[:button
|
||||
{:on-click (fn [_]
|
||||
(fetch-posts! {:continue? (fn [response]
|
||||
(seq (:body response)))}))}
|
||||
"Load all"]]]))
|
||||
^{:key idx} [:li.result [post {:post p}]]) displayed-posts)]]))
|
||||
|
||||
;; help section
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue