Repository navigation
feat(weather): add interactive widget forecast refresh - #629
Merged
Merged
Conversation
Platform: ios New(zh-Hant): iOS 天氣小工具可手動重新整理較舊或無法顯示的預報 New(en-US): iOS weather widgets can manually refresh outdated or unavailable forecasts
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 8 selected item(s). |
Codecov Report✅ All modified and coverable lines are covered by tests. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
YinCheng0106
marked this pull request as ready for review
October 17, 2026 18:01
6 tasks done
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.
這個 PR 做了什麼
在既有 iOS 天氣小工具加入預報手動重新整理:iOS 17 以上的中型/大型小工具在預報較舊、過期或無可顯示時段時顯示按鈕;保留 WidgetKit 自動更新及原有地點設定。
正式程式碼:
RefreshForecastIntent綁定小工具設定的 Current Location 或 Saved Location,驗證識別碼及已儲存地點目錄。Intent 不開啟 App、不直接呼叫 API、不寫快取、不額外呼叫 kind-wide reload;由 WidgetKit 在 Intent 完成後要求 timeline,沿用既有 Current Weather/Forecast API 更新流程。ForecastWidgetExpiry以校準後的 API 發布時間判定 Fresh/Stale/Expired:未滿 30 分鐘為 Fresh,30 分鐘至未滿 120 分鐘為 Stale,達 120 分鐘為 Expired。Stale 可顯示既有可用時段並標示「預報資料較舊」;Expired 不顯示預報。同一或較舊發布版本不能覆寫快取、改變原始 receivedAt 或延長效期。ForecastWidgetSelection以近期 Current Weather 觀測時間選取台北時間的下一整點;觀測缺少、無效、在未來或已達 30 分鐘時,改以校準時鐘選取。發布/接收時間只決定效期,不當作預報時段基準;保留 API 原始時段與既有 12 小時選取範圍。IntentConfiguration、Saved/Current Location 隔離、原有widgetURL、iOS 15/16 非互動 fallback 及 Small 不請求/不顯示預報的行為。新字串使用 Widget 原生 String Catalog,涵蓋既有五種語系。測試:
ForecastWidgetTests.swift擴充發布效期邊界、同發布版本不延長效期、觀測時間對齊、時區/校準偏移、地點隔離、Intent 驗證及按鈕顯示條件的回歸案例;Xcode 專案僅補入測試 target 的新 Intent 檔案 membership 設定。審查注意與已知限制:
isDiscoverable的 metadata 擷取/系統載入行為;較新 SDK 的建置成功不能證明這兩個版本可正常運作。相關 issue
已搜尋 Widget/forecast refresh,沒有對應的 issue。
怎麼驗
既有驗證(沿用前輪結果,不是本輪重新執行的完整 hosted XCTest):
git diff --check通過。本輪最終清理後驗證:
swiftc -frontend -parse通過。tool/check/l10n.sh、Xcode 專案plutil -lint、憑證樣式掃描及 staged diff whitespace 檢查通過。tool/commit.sh --message通過;當時 analyze/codegen/Dart coverage 使用既有成功快取。提交 hook 及提交後 commit 訊息檢查通過。檢查清單
tool/check/commits.sh origin/main..HEAD通過。tool/dev/analyze.sh與完整 Dart coverage 通過(由官方 pre-push hook 執行)。