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})
|
(-> (mastodon-request! {:url url :bearer-token bearer-token})
|
||||||
(.then (fn [response]
|
(.then (fn [response]
|
||||||
(let [url-params (url->search-params (.-url (:raw 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))]
|
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)
|
(on-response response)
|
||||||
(when (and (continue? response) next-url)
|
(if (and (continue? response) next-url)
|
||||||
(js/setTimeout #(paginate! next-url) 500)))))
|
(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]
|
(.catch (fn [response]
|
||||||
(swap! state update-in [:section/posts :loading] disj req-id)
|
(swap! state update-in [:section/posts :loading] disj req-id)
|
||||||
(on-error response))))))
|
(on-error response))))))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue