From 44170909a405b02e48e9d213d1c48c552a69d2d9 Mon Sep 17 00:00:00 2001
From: Mark Hulbert <39801222+m-hulbert@users.noreply.github.com>
Date: Fri, 6 Dec 2024 16:41:38 +0100
Subject: [PATCH] fixup! Updated to the recent swift API changes to fit JS.
---
content/chat/connect.textile | 31 +++++++++-------------------
content/chat/rooms/messages.textile | 10 ++++-----
content/chat/rooms/presence.textile | 4 +---
content/chat/rooms/reactions.textile | 10 +++------
content/chat/rooms/typing.textile | 4 ++--
content/chat/setup.textile | 17 ++++++---------
6 files changed, 27 insertions(+), 49 deletions(-)
diff --git a/content/chat/connect.textile b/content/chat/connect.textile
index c76e2551ee..8383f7336b 100644
--- a/content/chat/connect.textile
+++ b/content/chat/connect.textile
@@ -22,11 +22,8 @@ A connection can have any of the following statuses:
| suspended | A long term failure condition when no current connection exists because there is no network connectivity or available host. The suspended status is entered after a failed connection attempt if there has then been no connection for a period of two minutes. In the suspended status, an SDK will periodically attempt to open a new connection every 30 seconds. Rooms will be reattached on a successful reconnection, however message history will not be automatically recovered. |
| failed | This status is entered if the SDK encounters a failure condition that it cannot recover from. This may be a fatal connection error received from the Ably service, such as an attempt to connect with an incorrect API key, or some local terminal error, such as that the token in use has expired and the SDK does not have any way to renew it. |
-blang[javascript].
- Use the "@current@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.ConnectionStatus.html#current property to check which status a connection is currently in:
-
-blang[swift].
- Use the "@status@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.ConnectionStatus.html#status property to check which status a connection is currently in:
+blang[javascript,swift].
+ Use the "@current@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.ConnectionStatus.html#current"@status@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.ConnectionStatus.html#status property to check which status a connection is currently in:
blang[react].
Use the "@currentStatus@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-react.UseChatConnectionResponse.html#currentStatus property returned in the response of the "@useChatConnection@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/functions/chat-react.useChatConnection.html hook to check which status a connection is currently in:
@@ -76,7 +73,7 @@ blang[javascript,swift].
blang[react].
Listeners can also be registered to monitor the changes in connection status. Any hooks that take an optional listener to monitor their events, such as typing indicator events in the @useTyping@ hook, can also register a status change listener. Changing the value provided for a listener will cause the previously registered listener instance to stop receiving events. All messages will be received by exactly one listener.
-
+
```[javascript]
const { off } = chatClient.connection.status.onStatusChange((change) => console.log(change));
```
@@ -178,21 +175,13 @@ blang[javascript,swift].
subscription.unsubscribe()
```
+blang[react].
+
blang[javascript,swift].
The following discontinuity handlers are available:
-
-blang[react].
-blang[javascript].
- * "Messages":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Messages.html#onDiscontinuity
- * "Presence":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Presence.html#onDiscontinuity
- * "Occupancy":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Occupancy.html#onDiscontinuity
- * "Typing indicators":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Typing.html#onDiscontinuity
- * "Room reactions":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.RoomReactions.html#onDiscontinuity
-
-blang[swift].
- * "Messages":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.Messages.html#onDiscontinuity
- * "Presence":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.Presence.html#onDiscontinuity
- * "Occupancy":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.Occupancy.html#onDiscontinuity
- * "Typing indicators":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.Typing.html#onDiscontinuity
- * "Room reactions":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.RoomReactions.html#onDiscontinuity
+ * "Messages":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Messages.html#onDiscontinuity"Messages":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.Messages.html#onDiscontinuity
+ * "Presence":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Presence.html#onDiscontinuity"Presence":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.Presence.html#onDiscontinuity
+ * "Occupancy":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Occupancy.html#onDiscontinuity"Occupancy":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.Occupancy.html#onDiscontinuity
+ * "Typing indicators":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Typing.html#onDiscontinuity"Typing indicators":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.Typing.html#onDiscontinuity
+ * "Room reactions":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.RoomReactions.html#onDiscontinuity"Room reactions":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.RoomReactions.html#onDiscontinuity
diff --git a/content/chat/rooms/messages.textile b/content/chat/rooms/messages.textile
index e7b5b72099..a6eae352d4 100644
--- a/content/chat/rooms/messages.textile
+++ b/content/chat/rooms/messages.textile
@@ -110,11 +110,11 @@ blang[react].
blang[javascript,swift].
-
+
h2(#send). Send a message
diff --git a/content/chat/rooms/presence.textile b/content/chat/rooms/presence.textile
index 4c7179b1c2..6ae3b94a78 100644
--- a/content/chat/rooms/presence.textile
+++ b/content/chat/rooms/presence.textile
@@ -298,6 +298,7 @@ blang[javascript,swift].
```
blang[react].
+ Use the "@presenceData@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-react.UsePresenceListener.html#presenceData property available from the response of the @usePresence@ hook to view a list of all member's presence status in the room.
blang[javascript,swift].
Alternatively, use the "@presence.isUserPresent()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Presence.html#isUserPresent"@presence.isUserPresent()@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.Presence.html#isUserPresent method and pass in a user's @clientId@ to check whether they are online or not. This will return a boolean:
@@ -311,9 +312,6 @@ blang[javascript,swift].
```
blang[react].
- Use the "@presenceData@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-react.UsePresenceListener.html#presenceData property available from the response of the @usePresence@ hook to view a list of all member's presence status in the room.
-
-blang[javascript,swift].
h3(#member-structure). Presence member structure
diff --git a/content/chat/rooms/reactions.textile b/content/chat/rooms/reactions.textile
index f284daae47..7eaf61fd61 100644
--- a/content/chat/rooms/reactions.textile
+++ b/content/chat/rooms/reactions.textile
@@ -18,14 +18,12 @@ Room reactions are ephemeral and not stored or aggregated by Ably. The intention
h2(#subscribe). Subscribe to room reactions
-Room reactions events are emitted whenever a user sends a reaction, such as by hitting a 'like' button or clicking a heart emoji.
-
blang[javascript,swift].
Subscribe to room reactions by registering a listener. Use the "@reactions.subscribe()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.RoomReactions.html#subscribe"@reactions.subscribe()@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.RoomReactions.html#subscribe method in a room to receive reactions:
blang[react].
Subscribe to room reactions with the "@useRoomReactions@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/functions/chat_react.useRoomReactions.html hook. Supply an optional listener to receive the room reactions.
-
+
```[javascript]
const {unsubscribe} = room.reactions.subscribe((reaction) => {
console.log(`Received a reaction of type ${reaction.type}, and metadata ${reaction.metadata}`);
@@ -101,6 +99,7 @@ blang[javascript,swift].
```
blang[react].
+ When you unmount the component that is using the @useRoomReactions@ hook, it will automatically handle unsubscribing any associated listeners registered for room reactions.
blang[javascript].
Use the "@reactions.unsubscribeAll()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.RoomReactions.html#unsubscribeAll method to remove all reaction listeners in a room:
@@ -109,10 +108,7 @@ blang[javascript].
await room.reactions.unsubscribeAll();
```
-blang[react].
- When you unmount the component that is using the @useRoomReactions@ hook, it will automatically handle unsubscribing any associated listeners registered for room reactions.
-
-blang[javascript,swift].
+blang[react,swift].
h2(#send). Send a room reaction
diff --git a/content/chat/rooms/typing.textile b/content/chat/rooms/typing.textile
index 8fe2b04cea..9f8eb8939f 100644
--- a/content/chat/rooms/typing.textile
+++ b/content/chat/rooms/typing.textile
@@ -8,7 +8,7 @@ languages:
- swift
---
-Typing indicators enable you to display which users are currently writing a message in a room. This feature can be used to display a message such as __Sandi is typing...__, or when a certain threshold is reached you could instead display __Multiple people are typing...__ or _12 people are typing..._. Typing events can be emitted when a user starts or stops typing.
+Typing indicators enable you to display which users are currently writing a message in a room. This feature can be used to display a message such as __Sandi is typing...__, or when a certain threshold is reached you could instead display __Multiple people are typing...__ or _12 people are typing..._. Typing events are emitted whenever a user starts or stops typing.