Skip to content

Conversation

@jguz-pubnub
Copy link
Contributor

@jguz-pubnub jguz-pubnub commented Jul 18, 2025

feat(subscribe): add the ability to subscribe to presence channels only, without their main counterparts

@jguz-pubnub jguz-pubnub force-pushed the fix/subscribe-presence-channels branch from 5252f69 to 761f108 Compare July 18, 2025 13:02
@jguz-pubnub jguz-pubnub force-pushed the fix/subscribe-presence-channels branch from 761f108 to abed187 Compare July 21, 2025 08:54
Copy link
Contributor

@parfeon parfeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good!

/// Names of all subscribed main channels
///
/// This list does not include presence channel names
var mainChannelNames: [String] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds a bit strange... channelNames(_ withPresence: Bool)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense 👍 It's much more readable, I'll change it to your suggestion

Comment on lines 102 to 105
let channelsWithPresence = channels.filter { $0.isPresenceChannelName }.map { PubNubChannel(channel: $0) }
let channelsWithoutPresence = channels.filter { !$0.isPresenceChannelName }.map { PubNubChannel(channel: $0) }
let channelGroupsWithPresence = channelGroups.filter { $0.isPresenceChannelName }.map { PubNubChannel(channel: $0) }
let channelGroupsWithoutPresence = channelGroups.filter { !$0.isPresenceChannelName }.map { PubNubChannel(channel: $0) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have separate lists for with and without presence channels? We have separate variables and then aggregate them later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the legacy subscription mechanism I would like to finally remove, but unfortunately, we have to still keep it for backward compatibility. Anyway, I will provide an updated version for that

Comment on lines +180 to +181
let channelsToUnsubscribe = channels.flatMap { $0.isPresenceChannelName ? [$0] : [$0, $0.presenceChannelName] }
let channelGroupsToUnsubscribe = channelGroups.flatMap { $0.isPresenceChannelName ? [$0] : [$0, $0.presenceChannelName] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But presence channels won't be used for actual unsubscribe REST API, right?

Copy link
Contributor Author

@jguz-pubnub jguz-pubnub Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! And also, Presence channels won't be sent as parameters for join/leave events, but their "main" counterparts instead

@jguz-pubnub
Copy link
Contributor Author

@pubnub-release-bot release as 9.3.0

@jguz-pubnub jguz-pubnub force-pushed the fix/subscribe-presence-channels branch from 9f7c44d to 1c137df Compare July 29, 2025 10:15
@jguz-pubnub jguz-pubnub force-pushed the fix/subscribe-presence-channels branch from 1c137df to 39c5404 Compare July 29, 2025 10:17
@jguz-pubnub jguz-pubnub merged commit 1c6a045 into master Jul 29, 2025
12 checks passed
@jguz-pubnub jguz-pubnub deleted the fix/subscribe-presence-channels branch July 29, 2025 11:10
@pubnub-release-bot
Copy link

🚀 Release successfully completed 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants