File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -26,11 +26,21 @@ class ChatAdapter {
2626 }
2727 }
2828
29- static func associate( chat: ChatImpl , with kotlinChat: PubNubChat . ChatImpl ) {
30- queue. sync {
29+ static func associate( chat: ChatImpl , with kotlinChat: PubNubChat . ChatImpl ) {
30+ queue. sync {
31+ associations. removeAll {
32+ $0. isEmpty ( )
33+ }
34+ if let existing = associations. first ( where: {
35+ !$0. isEmpty ( ) && ( $0. chat === chat || $0. kotlinChat === kotlinChat)
36+ } ) {
37+ existing. _chat = chat
38+ existing. _kotlinChat = kotlinChat
39+ } else {
3140 associations. append ( . init( chat: chat, kotlinChat: kotlinChat) )
3241 }
3342 }
43+ }
3444
3545 static func clean( ) {
3646 queue. sync {
@@ -46,8 +56,8 @@ class ChatAdapter {
4656 // swiftlint:disable:next force_unwrapping
4757 var kotlinChat : PubNubChat . ChatImpl { _kotlinChat! }
4858
49- private weak var _chat : ChatImpl ?
50- private weak var _kotlinChat : PubNubChat . ChatImpl ?
59+ weak var _chat : ChatImpl ?
60+ weak var _kotlinChat : PubNubChat . ChatImpl ?
5161
5262 init ( chat: ChatImpl , kotlinChat: PubNubChat . ChatImpl ) {
5363 _chat = chat
You can’t perform that action at this time.
0 commit comments