From 1b54880e8a0c33efb605ed897b096595c67a3e12 Mon Sep 17 00:00:00 2001 From: arne Date: Fri, 21 Nov 2025 08:55:17 +0100 Subject: [PATCH] Prevent flickering when paginating requests --- src/computersandblues/lodestone/app.cljs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/computersandblues/lodestone/app.cljs b/src/computersandblues/lodestone/app.cljs index 1671a3c..7128011 100644 --- a/src/computersandblues/lodestone/app.cljs +++ b/src/computersandblues/lodestone/app.cljs @@ -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))))))