From 6c19e139f932cb7ed648d06005b709ea4012f2ea Mon Sep 17 00:00:00 2001 From: Jacob Bandes-Storch Date: Fri, 28 Jun 2024 18:14:25 -0700 Subject: [PATCH 1/2] Fix channels being advertised twice to new clients --- WebSocketDemo-Shared/FoxgloveServer.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WebSocketDemo-Shared/FoxgloveServer.swift b/WebSocketDemo-Shared/FoxgloveServer.swift index 21f1b14..d2b552e 100644 --- a/WebSocketDemo-Shared/FoxgloveServer.swift +++ b/WebSocketDemo-Shared/FoxgloveServer.swift @@ -134,12 +134,12 @@ class FoxgloveServer: ObservableObject { connection.stateUpdateHandler = { state in print("connection state \(state)") - if connection.state == .ready { + if state == .ready { self.sendInfo(connection) } let closed: Bool - switch connection.state { + switch state { case .cancelled, .failed: closed = true default: @@ -147,7 +147,7 @@ class FoxgloveServer: ObservableObject { } Task { @MainActor in - if !self.channels.isEmpty { + if state == .ready && !self.channels.isEmpty { try self.sendJson([ "op": "advertise", "channels": self.channels.values.map { From f1d8d9245d116962d84e185e36e2dfb7b200ff70 Mon Sep 17 00:00:00 2001 From: Richard Dancsi Date: Tue, 2 Jul 2024 15:09:28 +0100 Subject: [PATCH 2/2] fix(lint) --- WebSocketDemo-Shared/FoxgloveServer.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebSocketDemo-Shared/FoxgloveServer.swift b/WebSocketDemo-Shared/FoxgloveServer.swift index d2b552e..9a2634f 100644 --- a/WebSocketDemo-Shared/FoxgloveServer.swift +++ b/WebSocketDemo-Shared/FoxgloveServer.swift @@ -147,7 +147,7 @@ class FoxgloveServer: ObservableObject { } Task { @MainActor in - if state == .ready && !self.channels.isEmpty { + if state == .ready, !self.channels.isEmpty { try self.sendJson([ "op": "advertise", "channels": self.channels.values.map {