fix: auto-refresh remote backup directory when cache is stale [fix #310]#312
Merged
shuaiplus merged 1 commit intoJul 16, 2026
Merged
Conversation
When entering the cloud backup page, the remote backup directory list only showed cached data and required a manual click of the refresh button to see new backup files. This change adds a TTL-based auto-refresh that fetches fresh data when the cache is older than 5 minutes. Changes: - Added refreshedAt tracking per cache key in persisted state - Added REMOTE_BROWSER_REFRESH_TTL_MS (5 min) constant - Added useEffect that triggers auto-refresh when destination is selected and cached data is stale - Stamped refresh timestamps after successful API responses - Cleaned up timestamps on destination delete and settings save
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
远端备份目录浏览器 (
RemoteBackupBrowser) 会将远端存储的响应缓存到 localStorage 中以避免重复网络请求。此前,缓存只在用户手动点击"刷新"按钮或备份/删除操作后才会更新。如果用户在定时备份执行后进入页面,看到的仍然是旧数据。此变更在每个缓存键旁边记录上次刷新时间 (
refreshedAt)。一个useEffect在选中目标变化时(包括首次挂载)触发,将当前时间与记录的时间戳对比,如果超过 5 分钟则强制重新拉取数据。Change Type
Cross-File Checklist
CONTRIBUTING.md.migrations/0001_init.sql.Checks
npx tsc -p tsconfig.json --noEmitnpx tsc -p webapp/tsconfig.json --noEmitnpm run i18n:validatenpm run buildNotes
远端备份目录刷新场景清单
触发刷新的场景
useEffect→savedSelectedDestination?.id变化,检查refreshedAt过期trueBackupCenterPage.tsx:317-328lastRefreshed为 0 → 过期trueBackupCenterPage.tsx:317-328useEffect检测savedSelectedDestination?.id变化trueBackupCenterPage.tsx:317-328lastRefreshed为 0trueBackupCenterPage.tsx:317-328onRefreshRemoteBrowser回调trueBackupCenterPage.tsx:1006-1010executeRunRemoteBackup成功后trueBackupCenterPage.tsx:714executeDeleteRemote成功后trueBackupCenterPage.tsx:762refreshedAt,下次触发时重新拉取BackupCenterPage.tsx:687-692refreshedAtBackupCenterPage.tsx:555-565不触发刷新的场景
Date.now() - lastRefreshed <= TTL,跳过savedSelectedDestination?.id不变,useEffect不触发visibilitychange/focus事件监听