Skip to content

Commit

Permalink
Fix compilation on GH
Browse files Browse the repository at this point in the history
For some reason it compiles locally (Xcode 15), but doesn't compile on
GH (IDK what Xcode GH uses)
  • Loading branch information
nikitabobko committed Dec 1, 2023
1 parent 96522bc commit e7007f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: Build

on:
push:
branches: [ "main" ]
branches:
- 'main'
- 'bobko/**'
tags: [ "v**" ]
pull_request:
branches: [ "main" ]
Expand Down
15 changes: 9 additions & 6 deletions src/server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ private func newConnection(_ socket: Socket) { // todo add exit codes
guard let string = (try? socket.readString()) else { return }
let (action, error1) = parseCommand(string).getOrNils()
let (query, error2) = parseQueryCommand(string).getOrNils()
if DispatchQueue.main.asyncAndWait(execute: { !TrayMenuModel.shared.isEnabled }) &&
!isAllowedToRunWhenDisabled(query, action) {
guard let isEnabled: Bool = try? DispatchQueue.main.asyncAndWait(execute: { TrayMenuModel.shared.isEnabled }) else {
_ = try? socket.write(from: "Can't check if the server is enabled")
continue
}
if !isEnabled && !isAllowedToRunWhenDisabled(query, action) {
_ = try? socket.write(from: "\(Bundle.appName) server is disabled and doesn't accept commands. " +
"You can use 'aerospace enable on' to enable the server")
continue
Expand All @@ -52,22 +55,22 @@ private func newConnection(_ socket: Socket) { // todo add exit codes
continue
}
if let action {
DispatchQueue.main.asyncAndWait {
DispatchQueue.main.asyncAndWait(execute: {
refreshSession {
var focused = CommandSubject.focused // todo restore subject from "exec session"
action.run(&focused)
}
}
})
_ = try? socket.write(from: "PASS")
continue
}
if let query {
DispatchQueue.main.asyncAndWait {
DispatchQueue.main.asyncAndWait(execute: {
refreshSession {
let result = query.run()
_ = try? socket.write(from: result)
}
}
})
continue
}
error("Unreachable")
Expand Down

0 comments on commit e7007f3

Please sign in to comment.