From edae406dd2586f46dccaf0e70b2b876418d6c674 Mon Sep 17 00:00:00 2001 From: Lawrence Forooghian Date: Mon, 2 Dec 2024 17:27:26 -0300 Subject: [PATCH] =?UTF-8?q?Add=20an=20=E2=80=9Call=20features=20enabled?= =?UTF-8?q?=E2=80=9D=20room=20option?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In 20e7f5f I said > RoomOptionsDefaults in JS is instead implemented here by giving the > *Options types a no-args initializer that populates the default values. but I had not noticed that JS’s RoomOptionsDefaults is not actually a “default”, since the JS SDK does not even have a concept of a “default” RoomOptions. What it actually is is a RoomOptions in which all of the room features are switched on; we discussed this today in standup and Andy said that the intention of this value was to give users who are just playing around with the SDK an easy way to turn all features on. So, here, I add such an API for Swift, but with a name that more accurately describes its intention. Andy’s created [1] to revisit the JS naming. [1] https://ably.atlassian.net/browse/CHA-766 --- Example/AblyChatExample/ContentView.swift | 7 +------ Sources/AblyChat/RoomOptions.swift | 8 ++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Example/AblyChatExample/ContentView.swift b/Example/AblyChatExample/ContentView.swift index 58f3ec61..4f334144 100644 --- a/Example/AblyChatExample/ContentView.swift +++ b/Example/AblyChatExample/ContentView.swift @@ -56,12 +56,7 @@ struct ContentView: View { private func room() async throws -> Room { try await chatClient.rooms.get( roomID: roomID, - options: .init( - presence: .init(), - typing: .init(), - reactions: .init(), - occupancy: .init() - ) + options: .allFeaturesEnabled ) } diff --git a/Sources/AblyChat/RoomOptions.swift b/Sources/AblyChat/RoomOptions.swift index 4e1ace14..8259b8e5 100644 --- a/Sources/AblyChat/RoomOptions.swift +++ b/Sources/AblyChat/RoomOptions.swift @@ -6,6 +6,14 @@ public struct RoomOptions: Sendable, Equatable { public var reactions: RoomReactionsOptions? public var occupancy: OccupancyOptions? + /// A `RoomOptions` which enables all room features, using the default settings for each feature. + public static let allFeaturesEnabled: Self = .init( + presence: .init(), + typing: .init(), + reactions: .init(), + occupancy: .init() + ) + public init(presence: PresenceOptions? = nil, typing: TypingOptions? = nil, reactions: RoomReactionsOptions? = nil, occupancy: OccupancyOptions? = nil) { self.presence = presence self.typing = typing