fix: reduce idle interval indicator work
This commit is contained in:
@@ -29,7 +29,7 @@ struct ServerDetailView: View {
|
||||
@State private var progress: Double = 0
|
||||
@State private var showRestartSheet = false
|
||||
@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 {
|
||||
VStack(spacing: 0) {
|
||||
@@ -85,13 +85,21 @@ struct ServerDetailView: View {
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
.onReceive(timer) { _ in
|
||||
.onReceive(indicatorTimer) { _ in
|
||||
guard showIntervalIndicator else { return }
|
||||
withAnimation(.linear(duration: 1.0 / 60.0)) {
|
||||
progress += 1.0 / (Double(refreshInterval) * 60.0)
|
||||
withAnimation(.linear(duration: 1)) {
|
||||
progress += 1.0 / Double(refreshInterval)
|
||||
if progress >= 1 { progress = 0 }
|
||||
}
|
||||
}
|
||||
.onChange(of: refreshInterval) { _, _ in
|
||||
progress = 0
|
||||
}
|
||||
.onChange(of: showIntervalIndicator) { _, isVisible in
|
||||
if !isVisible {
|
||||
progress = 0
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $showRestartSheet) {
|
||||
RestartConfirmationSheet(
|
||||
hostname: server.hostname,
|
||||
|
||||
Reference in New Issue
Block a user