fix: interval indicator respects refresh interval setting

- ServerDetailView now reads refreshInterval from AppStorage
- Progress bar duration dynamically adjusts based on user's refresh interval setting
- Previously hardcoded to 60 seconds regardless of user preference
This commit is contained in:
Micha
2026-01-03 16:18:08 +01:00
parent 06932cde21
commit 4f026d6e1b
3 changed files with 13 additions and 5 deletions

View File

@@ -11,11 +11,12 @@ struct ServerDetailView: View {
@Binding var server: Server
var isFetching: Bool
@AppStorage("showIntervalIndicator") private var showIntervalIndicator: Bool = true
@AppStorage("refreshInterval") private var refreshInterval: Int = 60
private var showPlaceholder: Bool {
server.info == nil
}
@State private var progress: Double = 0
let timer = Timer.publish(every: 1.0 / 60.0, on: .main, in: .common).autoconnect()
@@ -59,7 +60,7 @@ struct ServerDetailView: View {
.onReceive(timer) { _ in
guard showIntervalIndicator else { return }
withAnimation(.linear(duration: 1.0 / 60.0)) {
progress += 1.0 / (60.0 * 60.0)
progress += 1.0 / (Double(refreshInterval) * 60.0)
if progress >= 1 { progress = 0 }
}
}