diff --git a/app/NativeMacReceiverSelector/AppDelegate.swift b/app/NativeMacReceiverSelector/AppDelegate.swift index 43b26bf..0fccf1d 100644 --- a/app/NativeMacReceiverSelector/AppDelegate.swift +++ b/app/NativeMacReceiverSelector/AppDelegate.swift @@ -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) } diff --git a/app/NativeMacReceiverSelector/ReceiverView.swift b/app/NativeMacReceiverSelector/ReceiverView.swift index 8a6b0ee..af23158 100644 --- a/app/NativeMacReceiverSelector/ReceiverView.swift +++ b/app/NativeMacReceiverSelector/ReceiverView.swift @@ -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) ]) diff --git a/app/NativeMacReceiverSelector/models/Receiver.swift b/app/NativeMacReceiverSelector/models/Receiver.swift index 16f293c..9c2b55e 100644 --- a/app/NativeMacReceiverSelector/models/Receiver.swift +++ b/app/NativeMacReceiverSelector/models/Receiver.swift @@ -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 } diff --git a/ext/src/types.ts b/ext/src/types.ts index 82ac9cc..e66e3fb 100644 --- a/ext/src/types.ts +++ b/ext/src/types.ts @@ -17,10 +17,9 @@ export interface Receiver { export interface ReceiverStatus { application: { displayName: string; - isIdleScreen: string; + isIdleScreen: boolean; statusText: string; }; - id: string; volume: { level: number; muted: boolean diff --git a/ext/src/ui/popup/index.tsx b/ext/src/ui/popup/index.tsx index 3340a41..7000804 100755 --- a/ext/src/ui/popup/index.tsx +++ b/ext/src/ui/popup/index.tsx @@ -235,9 +235,10 @@ class ReceiverEntry extends Component { { this.props.receiver.friendlyName }
- { `${this.props.receiver.host}:${this.props.receiver.port}` } + { this.props.receiver.status.application.isIdleScreen + ? `${this.props.receiver.host}:${this.props.receiver.port}` + : this.props.receiver.status.application.statusText }
-