karitham.dev website! atproto & fancy ssg + csr & blog articles karitham.dev
atproto gleam blog nix
0

Configure Feed

Select the types of activity you want to include in your feed.

client/src: fix refresh to only run on refresheable page

karitham (Jul 19, 2026, 1:39 PM +0200) 0f51efa4 8c9739b2

+17 -4
+3
client/src/browser.gleam
··· 10 10 @external(javascript, "./browser_ffi.mjs", "remove_attribute") 11 11 pub fn remove_attribute(id: String, name: String) -> Nil 12 12 13 + @external(javascript, "./browser_ffi.mjs", "has_element") 14 + pub fn has_element(id: String) -> Bool 15 + 13 16 @external(javascript, "./browser_ffi.mjs", "log_error") 14 17 pub fn log_error(message: String) -> Nil 15 18
+4
client/src/browser_ffi.mjs
··· 42 42 } 43 43 } 44 44 45 + export function has_element(id) { 46 + return document.getElementById(id) !== null; 47 + } 48 + 45 49 export function log_error(message) { 46 50 console.error(message); 47 51 }
+10 -4
client/src/refresh.gleam
··· 20 20 21 21 /// Wires up initial fetches, periodic poll, and visibility listener. 22 22 pub fn start() -> Nil { 23 - refresh_all() 24 - browser.localize_dates() 25 - browser.set_interval(plays_poll_ms, poll_tick) 26 - browser.on_visibility_change(on_visibility_change) 23 + // Guard: only run refresh logic on pages with dynamic sections. 24 + case browser.has_element("profile-section") { 25 + False -> Nil 26 + True -> { 27 + refresh_all() 28 + browser.localize_dates() 29 + browser.set_interval(plays_poll_ms, poll_tick) 30 + browser.on_visibility_change(on_visibility_change) 31 + } 32 + } 27 33 } 28 34 29 35 fn refresh_all() -> Nil {