From c4a1a8294fcae86b28bfde6ba5f84b6d69b383b2 Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Wed, 14 Feb 2024 02:58:06 +0800 Subject: [PATCH 1/2] feat: auto updates report lists --- src/main.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 1d2d5c5..9583293 100644 --- a/src/main.ts +++ b/src/main.ts @@ -69,7 +69,7 @@ const instance = app.mount("#app") as InstanceType; api.setApiKey(await setting.get("api.key")); - props.reports.push(...(await api.getReports(50))); + props.reports.push(...(await api.getReports())); props.stations.value = await api.getStations(); await browserWindow.setAlwaysOnTop(setting.settings.behavior.alwaysOnTop); @@ -79,6 +79,14 @@ const instance = app.mount("#app") as InstanceType; } else { disableAutoStart(); } + + timer.reportFetchTimer = window.setInterval(async () => { + const ids = props.reports.map((r) => r.id); + const reports = (await api.getReports()).filter((r) => !ids.includes(r.id)); + + props.reports.push(...reports); + props.reports.sort((a, b) => b.time - a.time); + }, 60_000); })(); let replayMode: boolean = false; From b5a51b2c410c315636f641e78c72c3f3b05ae4e0 Mon Sep 17 00:00:00 2001 From: Kamiya <58339640+kamiya10@users.noreply.github.com> Date: Wed, 14 Feb 2024 03:01:41 +0800 Subject: [PATCH 2/2] chore: changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c6984a..6283e61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * 新增開機時自動啟動的設定 (https://github.com/ExpTechTW/TREM-tauri/pull/30) * 新增最小化至系統匣的設定 (https://github.com/ExpTechTW/TREM-tauri/pull/30) * 新增啟動參數 `--quiet` 在開啟程式時隱藏視窗 (https://github.com/ExpTechTW/TREM-tauri/pull/30) +* 自動抓取並更新地震報告 (https://github.com/ExpTechTW/TREM-tauri/pull/32) **完整變更紀錄**: https://github.com/ExpTechTW/TREM-tauri/compare/v0.0.0-alpha.2...v0.0.0-alpha.3