diff --git a/.pubnub.yml b/.pubnub.yml index 36d53d33..552952f9 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,9 +1,14 @@ --- name: swift scm: github.com/pubnub/swift -version: "7.3.0" +version: "7.3.1" schema: 1 changelog: + - date: 2024-06-18 + version: 7.3.1 + changes: + - type: bug + text: "Calling .leave request in missing cases." - date: 2024-06-12 version: 7.3.0 changes: @@ -554,7 +559,7 @@ sdks: - distribution-type: source distribution-repository: GitHub release package-name: PubNub - location: https://github.com/pubnub/swift/archive/refs/tags/7.3.0.zip + location: https://github.com/pubnub/swift/archive/refs/tags/7.3.1.zip supported-platforms: supported-operating-systems: macOS: diff --git a/PubNub.xcodeproj/project.pbxproj b/PubNub.xcodeproj/project.pbxproj index e8af5d57..b60727ff 100644 --- a/PubNub.xcodeproj/project.pbxproj +++ b/PubNub.xcodeproj/project.pbxproj @@ -3847,7 +3847,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 7.3.0; + MARKETING_VERSION = 7.3.1; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -3898,7 +3898,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 7.3.0; + MARKETING_VERSION = 7.3.1; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; @@ -4006,7 +4006,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 7.3.0; + MARKETING_VERSION = 7.3.1; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -4059,7 +4059,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 7.3.0; + MARKETING_VERSION = 7.3.1; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; @@ -4180,7 +4180,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 7.3.0; + MARKETING_VERSION = 7.3.1; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -4232,7 +4232,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 7.3.0; + MARKETING_VERSION = 7.3.1; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; @@ -4712,7 +4712,7 @@ "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 7.3.0; + MARKETING_VERSION = 7.3.1; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++14"; OTHER_CFLAGS = "$(inherited)"; OTHER_LDFLAGS = "$(inherited)"; @@ -4754,7 +4754,7 @@ "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 7.3.0; + MARKETING_VERSION = 7.3.1; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++14"; OTHER_CFLAGS = "$(inherited)"; OTHER_LDFLAGS = "$(inherited)"; diff --git a/PubNubSwift.podspec b/PubNubSwift.podspec index 42f6f7c0..8a190c9b 100644 --- a/PubNubSwift.podspec +++ b/PubNubSwift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'PubNubSwift' - s.version = '7.3.0' + s.version = '7.3.1' s.homepage = 'https://github.com/pubnub/swift' s.documentation_url = 'https://www.pubnub.com/docs/swift-native/pubnub-swift-sdk' s.authors = { 'PubNub, Inc.' => 'support@pubnub.com' } diff --git a/Sources/PubNub/EventEngine/Presence/PresenceTransition.swift b/Sources/PubNub/EventEngine/Presence/PresenceTransition.swift index a5fc2a0e..1ea081c0 100644 --- a/Sources/PubNub/EventEngine/Presence/PresenceTransition.swift +++ b/Sources/PubNub/EventEngine/Presence/PresenceTransition.swift @@ -26,7 +26,7 @@ class PresenceTransition: TransitionProtocol { case .joined: return configuration.heartbeatInterval > 0 case .left: - return !(state is Presence.HeartbeatInactive) + return true case .heartbeatSuccess: return state is Presence.Heartbeating case .heartbeatFailed: @@ -34,7 +34,7 @@ class PresenceTransition: TransitionProtocol { case .timesUp: return state is Presence.HeartbeatCooldown case .leftAll: - return !(state is Presence.HeartbeatInactive) + return true case .disconnect: return !(state is Presence.HeartbeatInactive) case .reconnect: @@ -120,19 +120,22 @@ fileprivate extension PresenceTransition { channels: leaving.channels, groups: leaving.groups ) + let invocations = configuration.supressLeaveEvents ? [] : [ + EffectInvocation.regular(Presence.Invocation.leave( + channels: leaving.channels, + groups: leaving.groups + )) + ] + if state is Presence.HeartbeatStopped { return TransitionResult( state: Presence.HeartbeatStopped(input: newInput), - invocations: [] + invocations: invocations ) } else { - let leaveInvocation = EffectInvocation.regular(Presence.Invocation.leave( - channels: leaving.channels, - groups: leaving.groups - )) return TransitionResult( state: newInput.isEmpty ? Presence.HeartbeatInactive() : Presence.Heartbeating(input: newInput), - invocations: configuration.supressLeaveEvents ? [] : [leaveInvocation] + invocations: invocations ) } } diff --git a/Sources/PubNub/Helpers/Constants.swift b/Sources/PubNub/Helpers/Constants.swift index 740b004f..512ff8ed 100644 --- a/Sources/PubNub/Helpers/Constants.swift +++ b/Sources/PubNub/Helpers/Constants.swift @@ -57,7 +57,7 @@ public enum Constant { static let pubnubSwiftSDKName: String = "PubNubSwift" - static let pubnubSwiftSDKVersion: String = "7.3.0" + static let pubnubSwiftSDKVersion: String = "7.3.1" static let appBundleId: String = { if let info = Bundle.main.infoDictionary, diff --git a/Tests/PubNubTests/EventEngine/Presence/PresenceTransitionTests.swift b/Tests/PubNubTests/EventEngine/Presence/PresenceTransitionTests.swift index 5efc9944..fbf3b8f1 100644 --- a/Tests/PubNubTests/EventEngine/Presence/PresenceTransitionTests.swift +++ b/Tests/PubNubTests/EventEngine/Presence/PresenceTransitionTests.swift @@ -200,9 +200,12 @@ class PresenceTransitionTests: XCTestCase { let expectedState = Presence.HeartbeatStopped( input: PresenceInput(channels: ["c1", "c2"], groups: ["g1", "g2"]) ) + let expectedInvocations: [EffectInvocation] = [ + .regular(.leave(channels: ["c3"], groups: ["g3"])), + ] XCTAssertTrue(results.state.isEqual(to: expectedState)) - XCTAssertTrue(results.invocations.isEmpty) + XCTAssertTrue(results.invocations.elementsEqual(expectedInvocations)) } func testPresence_LeftEventForCooldownState() { @@ -294,6 +297,23 @@ class PresenceTransitionTests: XCTestCase { XCTAssertTrue(results.invocations.elementsEqual(expectedInvocations)) } + func testPresence_LeftAllForHeartbeatStoppedState() { + let input = PresenceInput( + channels: ["c1", "c2"], + groups: ["g1", "g2"] + ) + let results = transition.transition( + from: Presence.HeartbeatStopped(input: input), + event: .leftAll + ) + let expectedInvocations: [EffectInvocation] = [ + .regular(.leave(channels: ["c1", "c2"], groups: ["g1", "g2"])) + ] + + XCTAssertTrue(results.state.isEqual(to: Presence.HeartbeatInactive())) + XCTAssertTrue(results.invocations.elementsEqual(expectedInvocations)) + } + func testPresence_LeftAllForCooldownState() { let input = PresenceInput( channels: ["c1", "c2"],