diff --git a/Promptly.xcodeproj/project.xcworkspace/xcuserdata/sashabagrov.xcuserdatad/UserInterfaceState.xcuserstate b/Promptly.xcodeproj/project.xcworkspace/xcuserdata/sashabagrov.xcuserdatad/UserInterfaceState.xcuserstate index 0ea6227..77c56e5 100644 Binary files a/Promptly.xcodeproj/project.xcworkspace/xcuserdata/sashabagrov.xcuserdatad/UserInterfaceState.xcuserstate and b/Promptly.xcodeproj/project.xcworkspace/xcuserdata/sashabagrov.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Promptly/MQTT/MQTTManager.swift b/Promptly/MQTT/MQTTManager.swift index 032ebbb..7c58439 100644 --- a/Promptly/MQTT/MQTTManager.swift +++ b/Promptly/MQTT/MQTTManager.swift @@ -82,22 +82,27 @@ class MQTTManager: ObservableObject { client?.unsubscribe(from: topic) } - func subscribeToShowChanges(onChange: @escaping (String, String) -> Void) { + func subscribeToShowChanges(onChange: @escaping (String, String, String, String?) -> Void) { let showsPattern = "shows/#" client?.messagePublisher .filter { message in let components = message.topic.split(separator: "/") - return components.count == 2 && components.first == "shows" + return components.count >= 2 && components.first == "shows" } - .sink { message in + .sink { [weak self] message in let topic = message.topic let messageString = message.payload.string ?? "" + let components = topic.split(separator: "/").map(String.init) - if let showId = topic.split(separator: "/").last.map(String.init) { - DispatchQueue.main.async { - onChange(showId, messageString) - } + guard components.count >= 2 else { return } + + let showId = components[1] + let property = components.count > 2 ? components[2] : "" + let title = self?.receivedMessages["shows/\(showId)/title"] + + DispatchQueue.main.async { + onChange(showId, property, messageString, title) } } .store(in: &cancellables) diff --git a/Promptly/Views/Home Screen/HomeScreenView.swift b/Promptly/Views/Home Screen/HomeScreenView.swift index 0c44796..c7c36b2 100644 --- a/Promptly/Views/Home Screen/HomeScreenView.swift +++ b/Promptly/Views/Home Screen/HomeScreenView.swift @@ -16,7 +16,7 @@ struct HomeScreenView: View { @State var navStackMessage: String = "" @State var addShow: Bool = false @State var showNetworkSettings: Bool = false - @State var availableShows: [String] = [] + @State var availableShows: [String: String] = [:] @StateObject private var mqttManager = MQTTManager() @@ -38,9 +38,9 @@ struct HomeScreenView: View { mqttManager.connect(to: Constants.mqttIP, port: Constants.mqttPort) - mqttManager.subscribeToShowChanges { showId, message in - if UUID(uuidString: showId) != nil && !availableShows.contains(showId) { - availableShows.append(showId) + mqttManager.subscribeToShowChanges { showId, property, message, title in + if UUID(uuidString: showId) != nil && availableShows[showId] == nil { + availableShows[showId] = title ?? "Unknown Show" } } } @@ -81,9 +81,9 @@ struct HomeScreenView: View { Text("No available shows") .foregroundStyle(.secondary) } else { - ForEach(availableShows, id: \.self) { showId in + ForEach(Array(availableShows.keys), id: \.self) { showId in NavigationLink(destination: MultiPlayerShowDetail(showID: showId, mqttManager: self.mqttManager)) { - Text("Show \(showId)") + Text(availableShows[showId] ?? "Unknown Show") } } } diff --git a/Promptly/Views/Performance Mode/LivePerforemanceView.swift b/Promptly/Views/Performance Mode/LivePerforemanceView.swift index 28290fc..72943bb 100644 --- a/Promptly/Views/Performance Mode/LivePerforemanceView.swift +++ b/Promptly/Views/Performance Mode/LivePerforemanceView.swift @@ -1635,6 +1635,7 @@ extension DSMPerformanceView { } calledCues.insert(cue.id) + let execution = ReportCueExecution( timestamp: Date(), cueLabel: cue.label, @@ -1644,13 +1645,24 @@ extension DSMPerformanceView { ) cueExecutions.append(execution) + if cue.hasAlert { + showCueAlert() + } + if cue.type.isStandby { logCall("REMOTE STANDBY: \(cue.label)", type: .call) } else { logCall("REMOTE GO: \(cue.label)", type: .action) } - // SEND THE UPDATE HERE TOO + let timer = Timer.scheduledTimer(withTimeInterval: 5.0, repeats: false) { _ in + withAnimation(.easeOut(duration: 0.3)) { + hiddenCues.insert(cue.id) + } + cueHideTimers.removeValue(forKey: cue.id) + } + cueHideTimers[cue.id] = timer + let uuidStrings = calledCues.map { $0.uuidString } if let jsonData = try? JSONEncoder().encode(uuidStrings), let jsonString = String(data: jsonData, encoding: .utf8) {