diff --git a/ios/OTRNPublisherComponentView.swift b/ios/OTRNPublisherComponentView.swift index fe68b0fc..65ad9bf8 100644 --- a/ios/OTRNPublisherComponentView.swift +++ b/ios/OTRNPublisherComponentView.swift @@ -409,8 +409,8 @@ import React publisher.audioLevelDelegate = nil publisher.networkStatsDelegate = nil publisher.rtcStatsReportDelegate = nil - OTRN.sharedState.publishers[publisherId] = nil - OTRN.sharedState.isPublishing[publisherId] = nil + OTRN.sharedState.publishers.removeValue(forKey: publisherId) + OTRN.sharedState.isPublishing.removeValue(forKey: publisherId) self.publisherId = "" self.sessionId = "" self.currentSession = nil @@ -480,6 +480,7 @@ private class PublisherDelegateHandler: NSObject, OTPublisherKitDelegate { ) streamInfo["publisherId"] = publisherId OTRN.sharedState.publishers[publisherId] = nil + OTRN.sharedState.publishers.removeValue(forKey: publisherId) impl?.strictUIViewContainer?.handleStreamDestroyed(streamInfo) } } diff --git a/ios/OpentokReactNative.swift b/ios/OpentokReactNative.swift index 1d9daf76..4e9e2e2a 100644 --- a/ios/OpentokReactNative.swift +++ b/ios/OpentokReactNative.swift @@ -232,7 +232,6 @@ import React } session.unpublish(publisher, error: &error) - OTRN.sharedState.publishers.removeValue(forKey: publisherId) } @objc public func removeSubscriber(_ sessionId: String, streamId: String) { @@ -247,7 +246,6 @@ import React } session.unsubscribe(subscriber, error: &error) - OTRN.sharedState.subscribers.removeValue(forKey: streamId) } @objc public func forceMuteAll( @@ -488,6 +486,7 @@ private class SessionDelegateHandler: NSObject, OTSessionDelegate { let streamInfo: [String: Any] = EventUtils.prepareJSStreamEventData( stream) OTRN.sharedState.subscriberStreams.removeValue(forKey: stream.streamId) + OTRN.sharedState.subscribers.removeValue(forKey: stream.streamId) impl?.ot?.emit(onStreamDestroyed: streamInfo) }