Skip to content

Commit ad5d1d9

Browse files
jguz-pubnubclaude
andcommitted
Add limit and offset parameters to whoIsPresent methods
Co-Authored-By: Claude <noreply@anthropic.com>
1 parent d2b601e commit ad5d1d9

16 files changed

+56
-24
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ let package = Package(
1818
)
1919
],
2020
dependencies: [
21-
.package(url: "https://github.com/pubnub/kmp-chat", exact: "0.15.2-swift"),
22-
.package(url: "https://github.com/pubnub/swift", exact: "9.3.2")
21+
.package(url: "https://github.com/pubnub/kmp-chat", exact: "0.16.1-swift"),
22+
.package(url: "https://github.com/pubnub/swift", exact: "10.1.1")
2323
],
2424
targets: [
2525
// Targets are the basic building blocks of a package, defining a module or a test suite.

PubNubSwiftChatSDK.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,15 +1137,15 @@
11371137
repositoryURL = "https://github.com/pubnub/kmp-chat";
11381138
requirement = {
11391139
kind = exactVersion;
1140-
version = "0.15.2-swift";
1140+
version = "0.16.1-swift";
11411141
};
11421142
};
11431143
3DCF7DFA2CD0FFCC00889326 /* XCRemoteSwiftPackageReference "swift" */ = {
11441144
isa = XCRemoteSwiftPackageReference;
11451145
repositoryURL = "https://github.com/pubnub/swift";
11461146
requirement = {
11471147
kind = exactVersion;
1148-
version = 9.3.2;
1148+
version = 10.1.1;
11491149
};
11501150
};
11511151
/* End XCRemoteSwiftPackageReference section */

Sources/Chat/Chat+AsyncAwait.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,14 @@ public extension Chat {
336336

337337
/// Returns a list of ``User`` identifiers present on the given ``Channel``.
338338
///
339-
/// - Parameter channelId: Unique identifier of the channel where you want to check all present users
339+
/// - Parameters:
340+
/// - channelId: Unique identifier of the channel where you want to check all present users
341+
/// - limit: The number of occupants to fetch per channel. The maximum value is 1000
342+
/// - offset: The offset to return occupancy results from
340343
/// - Returns: A value containing collection of user identifiers
341-
func whoIsPresent(channelId: String) async throws -> [String] {
344+
func whoIsPresent(channelId: String, limit: Int = 1000, offset: Int? = 0) async throws -> [String] {
342345
try await withCheckedThrowingContinuation { continuation in
343-
whoIsPresent(channelId: channelId) {
346+
whoIsPresent(channelId: channelId, limit: limit, offset: offset) {
344347
switch $0 {
345348
case let .success(userIdentifiers):
346349
continuation.resume(returning: userIdentifiers)

Sources/Chat/Chat.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,15 @@ public protocol Chat: AnyObject {
256256
///
257257
/// - Parameters:
258258
/// - channelId: Unique identifier of the channel where you want to check all present users
259+
/// - limit: The number of occupants to fetch per channel. The maximum value is 1000
260+
/// - offset: The offset to return occupancy results from
259261
/// - completion: The async `Result` of the method call
260262
/// - **Success**: A value containing collection of user identifiers
261263
/// - **Failure**: An `Error` describing the failure
262264
func whoIsPresent(
263265
channelId: String,
266+
limit: Int,
267+
offset: Int?,
264268
completion: ((Swift.Result<[String], Error>) -> Void)?
265269
)
266270

Sources/Chat/ChatConfiguration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public enum LogLevel {
129129
/// The most verbose logging - print all other types of logs and more
130130
case verbose
131131

132-
func transform() -> PubNubChat.LogLevel {
132+
func transform() -> PubNubChat.LogLevel_ {
133133
switch self {
134134
case .off:
135135
.off

Sources/Chat/ChatImpl.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,14 @@ extension ChatImpl: Chat {
394394

395395
public func whoIsPresent(
396396
channelId: String,
397+
limit: Int = 1000,
398+
offset: Int? = 0,
397399
completion: ((Swift.Result<[String], Error>) -> Void)? = nil
398400
) {
399401
chat.whoIsPresent(
400-
channelId: channelId
402+
channelId: channelId,
403+
limit: Int32(limit),
404+
offset: offset?.asKotlinInt
401405
).async(caller: self) { (result: FutureResult<ChatImpl, [String]>) in
402406
switch result.result {
403407
case let .success(ids):

Sources/Entities/BaseChannel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ final class BaseChannel<C: PubNubChat.Channel_, M: PubNubChat.Message>: Channel
131131
)
132132
}
133133

134-
func whoIsPresent(completion: ((Swift.Result<[String], Error>) -> Void)?) {
135-
channel.whoIsPresent().async(caller: self) { (result: FutureResult<BaseChannel, [String]>) in
134+
func whoIsPresent(limit: Int, offset: Int?, completion: ((Swift.Result<[String], Error>) -> Void)?) {
135+
channel.whoIsPresent(limit: Int32(limit), offset: offset?.asKotlinInt).async(caller: self) { (result: FutureResult<BaseChannel, [String]>) in
136136
switch result.result {
137137
case let .success(userIdentifiers):
138138
completion?(.success(userIdentifiers))

Sources/Entities/Channel+AsyncAwait.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,13 @@ public extension Channel {
156156

157157
/// Returns a list of users present on the ``Channel``.
158158
///
159+
/// - Parameters:
160+
/// - limit: The number of occupants to fetch per channel. The maximum value is 1000
161+
/// - offset: The offset to return occupancy results from
159162
/// - Returns: A collection of strings representing `userId`
160-
func whoIsPresent() async throws -> [String] {
163+
func whoIsPresent(limit: Int = 1000, offset: Int? = 0) async throws -> [String] {
161164
try await withCheckedThrowingContinuation { continuation in
162-
whoIsPresent {
165+
whoIsPresent(limit: limit, offset: offset) {
163166
switch $0 {
164167
case let .success(collection):
165168
continuation.resume(returning: collection)

Sources/Entities/Channel.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,14 @@ public protocol Channel: CustomStringConvertible {
132132
/// Returns a list of users present on the ``Channel``.
133133
///
134134
/// - Parameters:
135+
/// - limit: The number of occupants to fetch per channel. The maximum value is 1000
136+
/// - offset: The offset to return occupancy results from
135137
/// - completion: The async `Result` of the method call
136138
/// - **Success**: A collection of strings representing `userId`
137139
/// - **Failure**: An `Error` describing the failure
138140
func whoIsPresent(
141+
limit: Int,
142+
offset: Int?,
139143
completion: ((Swift.Result<[String], Error>) -> Void)?
140144
)
141145

Sources/Entities/ChannelGroup+AsyncAwait.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,15 @@ public extension ChannelGroup {
122122

123123
/// Returns a collection of users currently present in any channel within the given ``ChannelGroup``.
124124
///
125+
/// - Parameters:
126+
/// - filter: Expression used to filter the results. Returns only the channels whose properties satisfy the given expression
127+
/// - sort: A collection to specify the sort order
128+
/// - limit: The number of occupants to fetch per channel. The maximum value is 1000
129+
/// - offset: The offset to return occupancy results from
125130
/// - Returns: A `Dictionary` where the key is a ``Channel`` identifier and the value is an array of present user identifiers
126-
func whoIsPresent() async throws -> [String: [String]] {
131+
func whoIsPresent(limit: Int = 1000, offset: Int? = 0) async throws -> [String: [String]] {
127132
try await withCheckedThrowingContinuation { continuation in
128-
whoIsPresent {
133+
whoIsPresent(limit: limit, offset: offset) {
129134
switch $0 {
130135
case let .success(result):
131136
continuation.resume(returning: result)

0 commit comments

Comments
 (0)