Prevent flickering when paginating requests
This commit is contained in:
parent
84109a3429
commit
1b54880e8a
1 changed files with 6 additions and 3 deletions
|
|
@ -258,11 +258,14 @@
|
|||
(-> (mastodon-request! {:url url :bearer-token bearer-token})
|
||||
(.then (fn [response]
|
||||
(let [url-params (url->search-params (.-url (:raw response)))
|
||||
timeout 500
|
||||
next-url (link-header (if (.get url-params "min_id") "prev" "next") (:raw response))]
|
||||
(swap! state update-in [:section/posts :loading] disj req-id)
|
||||
(on-response response)
|
||||
(when (and (continue? response) next-url)
|
||||
(js/setTimeout #(paginate! next-url) 500)))))
|
||||
(if (and (continue? response) next-url)
|
||||
(do
|
||||
(js/setTimeout #(paginate! next-url) timeout)
|
||||
(js/setTimeout #(swap! state update-in [:section/posts :loading] disj req-id) (+ timeout 16)))
|
||||
(swap! state update-in [:section/posts :loading] disj req-id)))))
|
||||
(.catch (fn [response]
|
||||
(swap! state update-in [:section/posts :loading] disj req-id)
|
||||
(on-error response))))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue