Use receiver application statusText instead of host:port when not idle

This commit is contained in:
hensm
2019-08-04 11:01:20 +01:00
parent 0fa1f63576
commit 8ac3cf49f5
5 changed files with 27 additions and 6 deletions

View File

@@ -24,7 +24,7 @@ class AppDelegate : NSObject, NSApplicationDelegate {
// Decode and store initialization JSON data
self.initData = try JSONDecoder().decode(InitData.self, from: data)
} catch {
fputs("Error: Failed to parse input data\n", stderr)
fputs("Error: Failed to parse input data\n (\(error))", stderr)
exit(1)
}

View File

@@ -37,9 +37,13 @@ class ReceiverView : NSStackView {
self.receiver = receiver
let statusText = receiver.status.application.isIdleScreen
? "\(receiver.host):\(receiver.port)"
: receiver.status.application.statusText
let metaStackView = NSStackView(views: [
makeLabel(receiver.friendlyName, size: 14)
, makeLabel("\(receiver.host):\(receiver.port)"
, makeLabel(statusText
, size: NSFont.smallSystemFontSize
, color: .secondaryLabelColor)
])

View File

@@ -1,6 +1,23 @@
struct Receiver : Codable {
struct Status: Codable {
let application: Application
let volume: Volume
}
struct Application: Codable {
let displayName: String
let isIdleScreen: Bool
let statusText: String
}
struct Volume: Codable {
let level: Double
let muted: Bool
}
let friendlyName: String
let host: String
let id: String
let port: Int
let status: Status
}