diff --git a/Sources/AblyChat/RoomLifecycleManager.swift b/Sources/AblyChat/RoomLifecycleManager.swift index 5a51b93a..fa856a87 100644 --- a/Sources/AblyChat/RoomLifecycleManager.swift +++ b/Sources/AblyChat/RoomLifecycleManager.swift @@ -22,7 +22,7 @@ internal actor RoomLifecycleManager { internal var channel: Channel } - internal private(set) var current: RoomLifecycle = .initialized + internal private(set) var current: RoomLifecycle internal private(set) var error: ARTErrorInfo? private let logger: InternalLogger @@ -30,20 +30,32 @@ internal actor RoomLifecycleManager { private let contributors: [Contributor] internal init(contributors: [Contributor], logger: InternalLogger, clock: SimpleClock) { - self.contributors = contributors - self.logger = logger - self.clock = clock + self.init( + current: .initialized, + contributors: contributors, + logger: logger, + clock: clock + ) } #if DEBUG internal init(testsOnly_current current: RoomLifecycle, contributors: [Contributor], logger: InternalLogger, clock: SimpleClock) { - self.current = current - self.contributors = contributors - self.logger = logger - self.clock = clock + self.init( + current: current, + contributors: contributors, + logger: logger, + clock: clock + ) } #endif + private init(current: RoomLifecycle, contributors: [Contributor], logger: InternalLogger, clock: SimpleClock) { + self.current = current + self.contributors = contributors + self.logger = logger + self.clock = clock + } + // TODO: clean up old subscriptions (https://github.com/ably-labs/ably-chat-swift/issues/36) private var subscriptions: [Subscription] = []