Skip to content

Commit

Permalink
Add an “all features enabled” room option
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lawrence-forooghian committed Dec 2, 2024
1 parent 5676cac commit 2fe43db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 1 addition & 6 deletions Example/AblyChatExample/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}

Expand Down
8 changes: 8 additions & 0 deletions Sources/AblyChat/RoomOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2fe43db

Please sign in to comment.