From fe240220295f9b9e75da42d691edfcf8967d4f50 Mon Sep 17 00:00:00 2001 From: RosieOh Date: Sun, 27 Sep 2026 03:11:08 +0900 Subject: [PATCH] =?UTF-8?q?FEAT:=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8=EC=9D=84=20=EC=8B=9C=EC=9E=91=ED=95=A0=20?= =?UTF-8?q?=EB=95=8C=EB=A7=88=EB=8B=A4=EC=99=80=20=EC=BC=9C=20=EB=91=94=20?= =?UTF-8?q?=EB=8F=99=EC=95=88=206=EC=8B=9C=EA=B0=84=EB=A7=88=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 하루 한 번만 확인해서, 설치 직후 새 버전이 나오면 다음 날까지 알 수 없었음. 시작할 때마다 확인하고 켜 둔 동안 6시간마다 다시 확인함. '나중에'로 닫은 버전은 이번 실행 동안 다시 띄우지 않음. Closes #41 --- app/src/main.ts | 2 +- app/src/update.ts | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/src/main.ts b/app/src/main.ts index a86d87d..8a4c73b 100644 --- a/app/src/main.ts +++ b/app/src/main.ts @@ -566,7 +566,7 @@ function registerCommands() { commands.installKeybindings(); void keybindings.load(); report.init(); - window.setTimeout(() => void update.check(false), 5000); + update.schedule(5000); } // ── 창 ───────────────────────────────────────────────── diff --git a/app/src/update.ts b/app/src/update.ts index 8a66e2f..aa900d6 100644 --- a/app/src/update.ts +++ b/app/src/update.ts @@ -1,12 +1,17 @@ -// 업데이트 확인. 시작할 때 하루 한 번 조용히 확인하고, 메뉴에서 직접 확인할 수도 있다. +// 업데이트 확인. 시작할 때마다, 그리고 켜 둔 동안 몇 시간마다 조용히 확인하고, 메뉴에서 직접 확인할 수도 있다. +// "나중에"로 닫은 버전은 이번 실행 동안 다시 띄우지 않는다 (다음에 켜면 다시 알린다). // 설치 파일은 서명을 검증한 뒤에만 설치된다 (tauri.conf.json의 plugins.updater.pubkey). import { invoke } from "@tauri-apps/api/core"; import { errorText } from "./api"; -import { store } from "./dom"; import * as toast from "./toast"; interface UpdateInfo { version: string; notes: string | null } -const DAY = 24 * 60 * 60 * 1000; +const HOURS = 60 * 60 * 1000; +/** 켜 둔 동안 다시 확인하는 간격 */ +const RECHECK = 6 * HOURS; + +/** 이번 실행에서 이미 알린 버전 (알림이 떠 있거나 "나중에"로 닫음) */ +const shown = new Set(); async function install(version: string) { const close = toast.show({ kind: "info", message: `Lantern ${version}을(를) 내려받는 중…`, detail: "설치가 끝나면 자동으로 다시 시작합니다.", timeout: 0 }); @@ -18,16 +23,16 @@ async function install(version: string) { } } -/** manual이면 결과(최신/실패)를 항상 알린다 */ +/** manual이면 결과(최신/실패)를 항상 알리고, 이미 알린 버전도 다시 띄운다 */ export async function check(manual: boolean) { - if (!manual && Date.now() - store.get("update.lastCheck", 0) < DAY) return; - store.set("update.lastCheck", Date.now()); try { const u = await invoke("check_update"); if (!u) { if (manual) toast.success("최신 버전을 쓰고 있습니다"); return; } + if (!manual && shown.has(u.version)) return; + shown.add(u.version); toast.show({ kind: "info", message: `새 버전 Lantern ${u.version}이(가) 있습니다`, @@ -39,3 +44,9 @@ export async function check(manual: boolean) { if (manual) toast.warn("업데이트를 확인하지 못했습니다", errorText(e)); } } + +/** 시작 직후 한 번, 그 뒤로 RECHECK마다 */ +export function schedule(firstDelayMs: number) { + window.setTimeout(() => void check(false), firstDelayMs); + window.setInterval(() => void check(false), RECHECK); +}