Skip to content

Commit 65043e0

Browse files
committed
Replace miss-used NSWorkspace notification center
1 parent 3ad7e55 commit 65043e0

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

Core/Sources/Service/XPCService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public class XPCService: NSObject, XPCServiceProtocol {
187187

188188
public func postNotification(name: String, withReply reply: @escaping () -> Void) {
189189
reply()
190-
NSWorkspace.shared.notificationCenter.post(name: .init(name), object: nil)
190+
NotificationCenter.default.post(name: .init(name), object: nil)
191191
}
192192

193193
// MARK: - Requests

Pro

Submodule Pro updated from 9c11324 to 67da617

Tool/Sources/AsyncPassthroughSubject/AsyncPassthroughSubject.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public actor AsyncPassthroughSubject<Element> {
2020
AsyncStream { [weak self, name] continuation in
2121
let task = Task { [weak self] in
2222
await self?.storeContinuation(continuation)
23-
let notifications = NSWorkspace.shared.notificationCenter.notifications(named: name)
23+
let notifications = NotificationCenter.default.notifications(named: name)
2424
.compactMap {
2525
$0.object as? Element
2626
}
@@ -46,7 +46,7 @@ public actor AsyncPassthroughSubject<Element> {
4646
}
4747

4848
func _send(_ element: Element) {
49-
NSWorkspace.shared.notificationCenter.post(name: name, object: element)
49+
NotificationCenter.default.post(name: name, object: element)
5050
}
5151

5252
func storeContinuation(_ continuation: AsyncStream<Element>.Continuation) {

Tool/Sources/OpenAIService/Debug/Debug.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ enum Debugger {
99
static func didSendRequestBody(body: CompletionRequestBody) {
1010
do {
1111
let json = try JSONEncoder().encode(body)
12-
let center = NSWorkspace.shared.notificationCenter
12+
let center = NotificationCenter.default
1313
center.post(
1414
name: .init("ServiceDebugger.ChatRequestDebug.requestSent"),
1515
object: nil,
@@ -24,7 +24,7 @@ enum Debugger {
2424
}
2525

2626
static func didReceiveFunction(name: String, arguments: String) {
27-
let center = NSWorkspace.shared.notificationCenter
27+
let center = NotificationCenter.default
2828
center.post(
2929
name: .init("ServiceDebugger.ChatRequestDebug.receivedFunctionCall"),
3030
object: nil,
@@ -37,7 +37,7 @@ enum Debugger {
3737
}
3838

3939
static func didReceiveFunctionResult(result: String) {
40-
let center = NSWorkspace.shared.notificationCenter
40+
let center = NotificationCenter.default
4141
center.post(
4242
name: .init("ServiceDebugger.ChatRequestDebug.receivedFunctionResult"),
4343
object: nil,
@@ -49,7 +49,7 @@ enum Debugger {
4949
}
5050

5151
static func didReceiveResponse(content: String) {
52-
let center = NSWorkspace.shared.notificationCenter
52+
let center = NotificationCenter.default
5353
center.post(
5454
name: .init("ServiceDebugger.ChatRequestDebug.responseReceived"),
5555
object: nil,
@@ -61,7 +61,7 @@ enum Debugger {
6161
}
6262

6363
static func didFinish() {
64-
let center = NSWorkspace.shared.notificationCenter
64+
let center = NotificationCenter.default
6565
center.post(
6666
name: .init("ServiceDebugger.ChatRequestDebug.finished"),
6767
object: nil,

Tool/Sources/XcodeInspector/XcodeInspector.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public final class XcodeInspector: ObservableObject {
222222
}
223223

224224
group.addTask { [weak self] in // malfunctioning
225-
let sequence = NSWorkspace.shared.notificationCenter
225+
let sequence = NotificationCenter.default
226226
.notifications(named: .accessibilityAPIMalfunctioning)
227227
for await notification in sequence {
228228
try Task.checkCancellation()
@@ -347,15 +347,15 @@ public final class XcodeInspector: ObservableObject {
347347
else { return }
348348

349349
if let editor = focusedEditor, !editor.element.isSourceEditor {
350-
NSWorkspace.shared.notificationCenter.post(
350+
NotificationCenter.default.post(
351351
name: .accessibilityAPIMalfunctioning,
352352
object: "Source Editor Element Corrupted: \(source)"
353353
)
354354
} else if let element = activeXcode?.appElement.focusedElement {
355355
if element.description != focusedElement?.description ||
356356
element.role != focusedElement?.role
357357
{
358-
NSWorkspace.shared.notificationCenter.post(
358+
NotificationCenter.default.post(
359359
name: .accessibilityAPIMalfunctioning,
360360
object: "Element Inconsistency: \(source)"
361361
)

0 commit comments

Comments
 (0)