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:
@@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user