Commit 2418261
Add frontend cache reset on consecutive pull-to-refresh within 10 seconds (#4235)
## Summary
Enables resetting the frontend cache via a double pull-to-refresh
gesture (within 10 seconds) in WebViewController, providing a
discoverable alternative to navigating through debug settings.
**Implementation:**
- Tracks pull-to-refresh timestamps to detect consecutive gestures
within 10-second window
- Triggers `cleanCache()` on second pull, provides haptic feedback
- Subsequent pulls within window continue resetting cache
- Pulls after 10+ seconds treated as new first pull
**Technical Details:**
- Added `lastPullToRefreshTimestamp` property to `WebViewController`
- Enhanced `pullToRefresh(_:)` method with time-window detection logic
- Uses existing `Current.websiteDataStoreHandler.cleanCache()`
infrastructure
- Comprehensive test coverage with mock `WebsiteDataStoreHandler`
```swift
@objc func pullToRefresh(_ sender: UIRefreshControl) {
let now = Current.date()
if let lastTimestamp = lastPullToRefreshTimestamp,
now.timeIntervalSince(lastTimestamp) < 10 {
// Cache reset path
Current.websiteDataStoreHandler.cleanCache { [weak self] in
self?.refresh()
self?.updateSensors()
}
lastPullToRefreshTimestamp = now
} else {
// Normal refresh path
lastPullToRefreshTimestamp = now
refresh()
updateSensors()
}
}
```
## Screenshots
N/A - Internal behavior change with haptic feedback only
## Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#
## Any other notes
Minimal change (+33 lines in WebViewController), leverages existing
cache clearing mechanism, testable via `Current.date()` abstraction.
<!-- START COPILOT CODING AGENT SUFFIX -->
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
> Reset frontend cache (DebugView) when user pull to refresh more than
once in WebViewController under 10 seconds
</details>
<!-- START COPILOT CODING AGENT TIPS -->
---
✨ Let Copilot coding agent [set things up for
you](https://github.com/home-assistant/iOS/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>1 parent 007604c commit 2418261
1 file changed
+29
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
| |||
865 | 868 | | |
866 | 869 | | |
867 | 870 | | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
868 | 897 | | |
869 | 898 | | |
870 | 899 | | |
| |||
0 commit comments