Skip to content

Commit b74cd5d

Browse files
committed
add check update interval
1 parent 270ea99 commit b74cd5d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/app/components/update.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,37 @@ export default function Update() {
4444
const [is_done_download, set_is_done_download] = createSignal(false);
4545

4646
let update_file_path:string = "";
47+
let update_checker_interval: NodeJS.Timeout;
48+
let is_checking_update:boolean = false;
4749

50+
/* Setup Update Checker Interval */
4851
onMount(()=>{
4952
check_update()
5053
.then(async (data) => {
5154
console.log(data);
5255
set_current_version(await getVersion());
5356
set_update_available(data);
5457
})
58+
59+
update_checker_interval = setInterval(()=>{
60+
if (is_checking_update) return;
61+
is_checking_update = true;
62+
check_update()
63+
.then(async (data) => {
64+
console.log(data);
65+
set_current_version(await getVersion());
66+
set_update_available(data);
67+
})
68+
.finally(()=>{
69+
is_checking_update = false;
70+
})
71+
}, 3600000);
72+
73+
onCleanup(() => {
74+
clearInterval(update_checker_interval);
75+
})
5576
})
77+
/* --- */
5678

5779
onMount(() => {
5880
let unlisten = () => {};

0 commit comments

Comments
 (0)