Skip to content

Commit f1c61fb

Browse files
cleanup
1 parent e3ecbfe commit f1c61fb

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Sources/LiveViewNative/Coordinators/LiveViewCoordinator.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ public class LiveViewCoordinator<R: RootRegistry>: ObservableObject {
272272
switch event.event {
273273
case .phoenix(phoenix: .error):
274274
logger.error("encountered error in reply - channel reconnecting");
275+
if let liveChannel {
276+
let channel = liveChannel.channel()
277+
try await channel.shutdown()
278+
}
275279
try await session.joinLiveViewChannel()
276280
case .user(user: "diff"):
277281
switch event.payload {
@@ -345,12 +349,6 @@ public class LiveViewCoordinator<R: RootRegistry>: ObservableObject {
345349
}
346350

347351
func join(_ liveChannel: LiveViewNativeCore.LiveChannel) {
348-
if let old = self.liveChannel {
349-
let channel = old.channel()
350-
Task { @MainActor in
351-
try await channel.shutdown()
352-
}
353-
}
354352

355353
self.liveChannel = liveChannel
356354
let channel = liveChannel.channel()

0 commit comments

Comments
 (0)