this repo has no description plcbundle-watch.pages.dev

update auto refresh

+4 -5
+4 -5
src/App.svelte
··· 8 8 9 9 const PLC_DIRECTORY = 'plc.directory' 10 10 const ROOT = 'cbab6809a136d6a621906ee11199d3b0faf85b422fe0d0d2c346ce8e9dcd7485' 11 - const AUTO_REFRESH_INTERVAL = 15 // in seconds 11 + const AUTO_REFRESH_INTERVAL = 10 // in seconds 12 12 const BUNDLE_OPS = 10_000 13 13 14 14 type Instance = { ··· 43 43 let url: string = instance.url; 44 44 const start = performance.now(); 45 45 try { 46 - statusResp = await (await fetch(`${url}/status`)).json() 46 + statusResp = await (await fetch(`${url}/status?${Number(new Date())}`)).json() 47 47 } catch (e) {} 48 48 if (!statusResp) { 49 49 url = `https://keyoxide.org/api/3/get/http?url=${encodeURIComponent(url)}&format=text&time=${Date.now()}` ··· 106 106 107 107 recalculateHead() 108 108 })) 109 - 110 109 isUpdating = false 111 - setTimeout(() => (canRefresh = false), 1000) 110 + setTimeout(() => { canRefresh = true }, 500) 112 111 } 113 112 114 113 onMount(async () => { ··· 137 136 <Switch.Label>Auto-refresh ({AUTO_REFRESH_INTERVAL}s)</Switch.Label> 138 137 <Switch.HiddenInput /> 139 138 </Switch> 140 - <button type="button" class="btn btn-sm preset-tonal-primary" onclick={() => doCheck()} disabled={canRefresh}>Refresh</button> 139 + <button type="button" class="btn btn-sm preset-tonal-primary" onclick={() => doCheck()} disabled={isUpdating || canRefresh === false}>Refresh</button> 141 140 </div> 142 141 </header> 143 142