Prevent flickering when paginating requests

This commit is contained in:
arne 2025-11-21 08:55:17 +01:00
commit 1b54880e8a

View file

@ -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))))))