Skip to content

Commit

Permalink
Fix according to review (separate vars for affected channels/groups)
Browse files Browse the repository at this point in the history
  • Loading branch information
jguz-pubnub committed Sep 17, 2024
1 parent b3a3bb6 commit 32d0e57
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Sources/PubNub/KMP/KMPPubNub+Listeners.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,44 @@ extension KMPPubNub {

let category: KMPConnectionStatusCategory
let errorIfAny: Error?
let affectedChannels: [String]
let affectedGroups: [String]

switch newStatus {
case .connected:
category = .connected
errorIfAny = nil
affectedChannels = pubnub.subscribedChannels
affectedGroups = pubnub.subscribedChannelGroups
case .disconnected:
category = .disconnected
errorIfAny = nil
affectedChannels = pubnub.subscribedChannels
affectedGroups = pubnub.subscribedChannelGroups
case let .disconnectedUnexpectedly(error):
category = .disconnectedUnexpectedly
errorIfAny = error
case .subscriptionChanged:
affectedChannels = pubnub.subscribedChannels
affectedGroups = pubnub.subscribedChannelGroups
case let .subscriptionChanged(channels, groups):
category = .subscriptionChanged
errorIfAny = nil
affectedChannels = channels
affectedGroups = groups
case let .connectionError(error):
category = .connectionError
errorIfAny = error
affectedChannels = pubnub.subscribedChannels
affectedGroups = pubnub.subscribedChannelGroups
}

listener.onStatusChange?(
KMPConnectionStatus(
category: category,
error: errorIfAny,
currentTimetoken: NSNumber(value: pubnub.previousTimetoken ?? 0),
affectedChannels: Set(pubnub.subscribedChannels),
affectedChannelGroups: Set(pubnub.subscribedChannelGroups)
affectedChannels: Set(affectedChannels),
affectedChannelGroups: Set(affectedGroups)
)
)
})
Expand Down

0 comments on commit 32d0e57

Please sign in to comment.