Skip to content

Commit

Permalink
Merge pull request #32 from ExpTechTW/feat/auto-update-reports
Browse files Browse the repository at this point in the history
feat: auto updates report lists
  • Loading branch information
whes1015 committed Feb 14, 2024
2 parents e65b397 + 9278d1b commit bce86a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* 新增最小化至系統匣的設定 (https://github.com/ExpTechTW/TREM-tauri/pull/30)
* 新增啟動參數 `--quiet` 在開啟程式時隱藏視窗 (https://github.com/ExpTechTW/TREM-tauri/pull/30)
* 停用瀏覽器內建快捷鍵 (https://github.com/ExpTechTW/TREM-tauri/pull/31)
* 自動抓取並更新地震報告 (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

Expand Down
10 changes: 9 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const instance = app.mount("#app") as InstanceType<typeof App>;

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);
Expand All @@ -79,6 +79,14 @@ const instance = app.mount("#app") as InstanceType<typeof App>;
} 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;
Expand Down

0 comments on commit bce86a4

Please sign in to comment.