diff --git a/PubNubSwiftChatSDK.xcodeproj/project.pbxproj b/PubNubSwiftChatSDK.xcodeproj/project.pbxproj index 9e3b610..a31fa23 100644 --- a/PubNubSwiftChatSDK.xcodeproj/project.pbxproj +++ b/PubNubSwiftChatSDK.xcodeproj/project.pbxproj @@ -20,7 +20,7 @@ 3D2CA2482C621876008D2284 /* MessageActionType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D2CA2472C621876008D2284 /* MessageActionType.swift */; }; 3D334BD02C8EE9E500F8793C /* PubNub.PushService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D334BCF2C8EE9E500F8793C /* PubNub.PushService.swift */; }; 3D334BD22C8EEAA800F8793C /* PubNub.PushEnvironment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D334BD12C8EEAA800F8793C /* PubNub.PushEnvironment.swift */; }; - 3D79EB842D0C39C100F7AB56 /* PubNubChat in Frameworks */ = {isa = PBXBuildFile; productRef = 3D79EB832D0C39C100F7AB56 /* PubNubChat */; }; + 3D60C28C2D0CDC0A00C17981 /* PubNubChat in Frameworks */ = {isa = PBXBuildFile; productRef = 3D60C28B2D0CDC0A00C17981 /* PubNubChat */; }; 3D79EB862D0C40ED00F7AB56 /* PubNubChat.PubNubError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D79EB852D0C40ED00F7AB56 /* PubNubChat.PubNubError.swift */; }; 3D7BBF6F2C8893D400FBA623 /* ChatAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D7BBF6E2C8893D400FBA623 /* ChatAdapter.swift */; }; 3D83621A2CC7B35200A21B9A /* MessageDraftChangeListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D8362192CC7B35200A21B9A /* MessageDraftChangeListener.swift */; }; @@ -192,7 +192,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 3D79EB842D0C39C100F7AB56 /* PubNubChat in Frameworks */, + 3D60C28C2D0CDC0A00C17981 /* PubNubChat in Frameworks */, 3DCF7DFC2CD0FFCC00889326 /* PubNubSDK in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -401,7 +401,7 @@ name = PubNubSwiftChatSDK; packageProductDependencies = ( 3DCF7DFB2CD0FFCC00889326 /* PubNubSDK */, - 3D79EB832D0C39C100F7AB56 /* PubNubChat */, + 3D60C28B2D0CDC0A00C17981 /* PubNubChat */, ); productName = PubNubChatSDK; productReference = 3DB73A072C4FE13C007FE249 /* PubNubSwiftChatSDK.framework */; @@ -455,7 +455,7 @@ mainGroup = 3DB739FD2C4FE13B007FE249; packageReferences = ( 3DCF7DFA2CD0FFCC00889326 /* XCRemoteSwiftPackageReference "swift" */, - 3D79EB822D0C39C100F7AB56 /* XCRemoteSwiftPackageReference "kmp-chat" */, + 3D60C28A2D0CDC0A00C17981 /* XCRemoteSwiftPackageReference "kmp-chat" */, ); productRefGroup = 3DB73A082C4FE13C007FE249 /* Products */; projectDirPath = ""; @@ -881,7 +881,7 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - 3D79EB822D0C39C100F7AB56 /* XCRemoteSwiftPackageReference "kmp-chat" */ = { + 3D60C28A2D0CDC0A00C17981 /* XCRemoteSwiftPackageReference "kmp-chat" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/pubnub/kmp-chat"; requirement = { @@ -900,9 +900,9 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - 3D79EB832D0C39C100F7AB56 /* PubNubChat */ = { + 3D60C28B2D0CDC0A00C17981 /* PubNubChat */ = { isa = XCSwiftPackageProductDependency; - package = 3D79EB822D0C39C100F7AB56 /* XCRemoteSwiftPackageReference "kmp-chat" */; + package = 3D60C28A2D0CDC0A00C17981 /* XCRemoteSwiftPackageReference "kmp-chat" */; productName = PubNubChat; }; 3DCF7DFB2CD0FFCC00889326 /* PubNubSDK */ = { diff --git a/Sources/Entities/BaseChannel.swift b/Sources/Entities/BaseChannel.swift index 4c2b6ad..f7c7292 100644 --- a/Sources/Entities/BaseChannel.swift +++ b/Sources/Entities/BaseChannel.swift @@ -95,22 +95,22 @@ final class BaseChannel: Channel } } - func startTyping(completion: ((Swift.Result) -> Void)?) { - channel.startTyping().async(caller: self) { (result: FutureResult) in + func startTyping(completion: ((Swift.Result) -> Void)?) { + channel.startTyping().async(caller: self) { (result: FutureResult) in switch result.result { - case .success: - completion?(.success(())) + case let .success(publishRes): + completion?(.success(publishRes?.timetoken.asTimetoken())) case let .failure(error): completion?(.failure(error)) } } } - func stopTyping(completion: ((Swift.Result) -> Void)?) { - channel.stopTyping().async(caller: self) { (result: FutureResult) in + func stopTyping(completion: ((Swift.Result) -> Void)?) { + channel.stopTyping().async(caller: self) { (result: FutureResult) in switch result.result { - case .success: - completion?(.success(())) + case let .success(publishRes): + completion?(.success(publishRes?.timetoken.asTimetoken())) case let .failure(error): completion?(.failure(error)) } @@ -274,9 +274,7 @@ final class BaseChannel: Channel case let .success(response): completion?(.success( ( - memberships: response.members.compactMap { - $0 as? PubNubChat.Membership - }.map { + memberships: response.members.map { MembershipImpl(membership: $0) }, page: PubNubHashedPageBase( diff --git a/Sources/Entities/Channel.swift b/Sources/Entities/Channel.swift index bcd0980..549025a 100644 --- a/Sources/Entities/Channel.swift +++ b/Sources/Entities/Channel.swift @@ -97,20 +97,20 @@ public protocol Channel { /// /// - Parameters: /// - completion: The async `Result` of the method call - /// - **Success**: A `Void` indicating a success + /// - **Success**: A `Timetoken` indicating the action timestamp /// - **Failure**: An `Error` describing the failure func startTyping( - completion: ((Swift.Result) -> Void)? + completion: ((Swift.Result) -> Void)? ) /// Deactivates a typing indicator on a given channel. /// /// - Parameters: /// - completion: The async `Result` of the method call - /// - **Success**: A `Void` indicating a success + /// - **Success**: A `Timetoken` indicating the action timestamp /// - **Failure**: An `Error` describing the failure func stopTyping( - completion: ((Swift.Result) -> Void)? + completion: ((Swift.Result) -> Void)? ) /// Enables continuous tracking of typing activity within the ``Channel``. diff --git a/Sources/Entities/ChannelImpl.swift b/Sources/Entities/ChannelImpl.swift index 82666ea..01424be 100644 --- a/Sources/Entities/ChannelImpl.swift +++ b/Sources/Entities/ChannelImpl.swift @@ -123,13 +123,13 @@ extension ChannelImpl: Channel { ) } - public func startTyping(completion: ((Swift.Result) -> Void)? = nil) { + public func startTyping(completion: ((Swift.Result) -> Void)? = nil) { target.startTyping( completion: completion ) } - public func stopTyping(completion: ((Swift.Result) -> Void)? = nil) { + public func stopTyping(completion: ((Swift.Result) -> Void)? = nil) { target.stopTyping( completion: completion ) diff --git a/Sources/Entities/ThreadChannelImpl.swift b/Sources/Entities/ThreadChannelImpl.swift index e585799..8d1d8d1 100644 --- a/Sources/Entities/ThreadChannelImpl.swift +++ b/Sources/Entities/ThreadChannelImpl.swift @@ -151,13 +151,13 @@ extension ThreadChannelImpl: ThreadChannel { ) } - public func startTyping(completion: ((Swift.Result) -> Void)? = nil) { + public func startTyping(completion: ((Swift.Result) -> Void)? = nil) { target.startTyping( completion: completion ) } - public func stopTyping(completion: ((Swift.Result) -> Void)? = nil) { + public func stopTyping(completion: ((Swift.Result) -> Void)? = nil) { target.stopTyping( completion: completion ) diff --git a/Sources/Extensions/Timetoken.swift b/Sources/Extensions/Timetoken.swift index a255257..7074cbc 100644 --- a/Sources/Extensions/Timetoken.swift +++ b/Sources/Extensions/Timetoken.swift @@ -17,3 +17,9 @@ extension Timetoken { KotlinLong(value: Int64(self)) } } + +extension Int64 { + func asTimetoken() -> Timetoken { + Timetoken(self) + } +} diff --git a/Tests/ChannelIntegrationTests.swift b/Tests/ChannelIntegrationTests.swift index 5a7e8ec..d2159f3 100644 --- a/Tests/ChannelIntegrationTests.swift +++ b/Tests/ChannelIntegrationTests.swift @@ -165,11 +165,9 @@ class ChannelIntegrationTests: PubNubSwiftChatSDKIntegrationTests { } func testChannel_StopTyping() throws { - XCTAssertNotNil( - try awaitResultValue { - channel.stopTyping(completion: $0) - } - ) + try awaitResultValue { + channel.stopTyping(completion: $0) + } } func testChannel_WhoIsPresent() throws {