fix: reduce idle interval indicator work

This commit is contained in:
2026-04-19 23:02:51 +02:00
parent d978c51fbd
commit 9be8d41c94
2 changed files with 16 additions and 4 deletions

View File

@@ -1,5 +1,9 @@
# Changelog # Changelog
## 26.1.9
- Reduced idle CPU usage and energy impact by changing the interval indicator from a permanent 60 FPS timer to a 1-second update cadence.
- Reset the interval indicator cleanly when the refresh interval changes or when the indicator is hidden.
## 26.1.8 ## 26.1.8
- Fixed a crash in `PingService` caused by concurrent mutation of shared ping state from multiple async ping tasks. - Fixed a crash in `PingService` caused by concurrent mutation of shared ping state from multiple async ping tasks.
- Moved ping state tracking and reboot suppression windows into an actor so ping success/failure handling is serialized safely. - Moved ping state tracking and reboot suppression windows into an actor so ping success/failure handling is serialized safely.

View File

@@ -29,7 +29,7 @@ struct ServerDetailView: View {
@State private var progress: Double = 0 @State private var progress: Double = 0
@State private var showRestartSheet = false @State private var showRestartSheet = false
@State private var restartFeedback: ServerActionFeedback? @State private var restartFeedback: ServerActionFeedback?
let timer = Timer.publish(every: 1.0 / 60.0, on: .main, in: .common).autoconnect() private let indicatorTimer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()
var body: some View { var body: some View {
VStack(spacing: 0) { VStack(spacing: 0) {
@@ -85,13 +85,21 @@ struct ServerDetailView: View {
.padding() .padding()
} }
} }
.onReceive(timer) { _ in .onReceive(indicatorTimer) { _ in
guard showIntervalIndicator else { return } guard showIntervalIndicator else { return }
withAnimation(.linear(duration: 1.0 / 60.0)) { withAnimation(.linear(duration: 1)) {
progress += 1.0 / (Double(refreshInterval) * 60.0) progress += 1.0 / Double(refreshInterval)
if progress >= 1 { progress = 0 } if progress >= 1 { progress = 0 }
} }
} }
.onChange(of: refreshInterval) { _, _ in
progress = 0
}
.onChange(of: showIntervalIndicator) { _, isVisible in
if !isVisible {
progress = 0
}
}
.sheet(isPresented: $showRestartSheet) { .sheet(isPresented: $showRestartSheet) {
RestartConfirmationSheet( RestartConfirmationSheet(
hostname: server.hostname, hostname: server.hostname,