Skip to content

Commit

Permalink
Fix CI build for macOS (Swift 5.7 didn't like some implicit self) and…
Browse files Browse the repository at this point in the history
… Linux (accidentally didn't gate objc key-value observation)
  • Loading branch information
stackotter committed Nov 12, 2023
1 parent c7591a3 commit 0907800
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Sources/Client/Controller/Controller.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ class Controller: ObservableObject {
// Some buttons set multiple updates when changing states because they're
// analog (like the triggers on the PS5 controller), so we need to filter
// those updates out.
guard newState != buttonStates[button.rawValue] else {
guard newState != self.buttonStates[button.rawValue] else {
continue
}

buttonStates[button.rawValue] = newState
self.buttonStates[button.rawValue] = newState
if newState {
eventSubject.send(.buttonPressed(button))
self.eventSubject.send(.buttonPressed(button))
} else {
eventSubject.send(.buttonReleased(button))
self.eventSubject.send(.buttonReleased(button))
}
}

Expand All @@ -97,9 +97,9 @@ class Controller: ObservableObject {

let x = thumbstickElement.xAxis.value
let y = thumbstickElement.yAxis.value
thumbstickStates[thumbstick.rawValue].x = x
thumbstickStates[thumbstick.rawValue].y = y
eventSubject.send(.thumbstickMoved(thumbstick, x: x, y: y))
self.thumbstickStates[thumbstick.rawValue].x = x
self.thumbstickStates[thumbstick.rawValue].y = y
self.eventSubject.send(.thumbstickMoved(thumbstick, x: x, y: y))
}
}

Expand Down
4 changes: 4 additions & 0 deletions Sources/Core/Sources/Util/Task/TaskProgress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ public final class TaskProgress<Step: TaskStep> {
/// A handler to call whenever the progress changes.
private var changeHandler: ((TaskProgress<Step>) -> Void)?

#if canImport(Darwin)
/// A handle to the observation of a step's nested `Progress`. Required to keep
/// the handle alive until the step completes.
private var observation: NSKeyValueObservation?
#endif

/// The total combined duration of all steps. There is no unit, it is just the sum
/// of relative durations. Excludes ``TaskProgress/skippedSteps``.
Expand Down Expand Up @@ -210,6 +212,7 @@ public final class TaskProgress<Step: TaskStep> {
return try action(innerProgress)
}

#if canImport(Darwin)
// TODO: This feels a bit janky and less intuitive than the other methods. Perhaps a more descriptive
// method name would help.
/// Performs a step with a nested progress tracker. The step is given a way to register
Expand Down Expand Up @@ -253,4 +256,5 @@ public final class TaskProgress<Step: TaskStep> {

return result
}
#endif
}

0 comments on commit 0907800

Please sign in to comment.