Skip to content

Commit 344e9f4

Browse files
committed
[ECO-4899] chore: rename Direction into more meaningful MessageOrder
Also added TODO for `Messages#send` function, right now in the Chat JS documentation mentioned that it's behavior is non-deterministic, which is not very good for DX
1 parent 8c06949 commit 344e9f4

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

chat-android/src/main/java/com/ably/chat/Messages.kt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,17 @@ interface Messages : EmitsDiscontinuities {
4444
*
4545
* This method uses the Ably Chat API endpoint for sending messages.
4646
*
47-
* Note that the Promise may resolve before OR after the message is received
47+
* Note: that the suspending function may resolve before OR after the message is received
4848
* from the realtime channel. This means you may see the message that was just
49-
* sent in a callback to `subscribe` before the returned promise resolves.
49+
* sent in a callback to `subscribe` before the function resolves.
50+
*
51+
* TODO: Revisit this resolution policy during implementation (it will be much better for DX if this behavior is deterministic).
5052
*
5153
* @param params an object containing {text, headers, metadata} for the message
5254
* to be sent. Text is required, metadata and headers are optional.
53-
* @returns A promise that resolves when the message was published.
55+
* @returns The message was published.
5456
*/
55-
fun send(params: SendMessageParams): Message
57+
suspend fun send(params: SendMessageParams): Message
5658

5759
/**
5860
* An interface for listening to new messaging event
@@ -92,23 +94,23 @@ data class QueryOptions(
9294
val limit: Int = 100,
9395

9496
/**
95-
* The direction to query messages in.
97+
* The order of messages in the query result.
9698
*/
97-
val direction: Direction = Direction.FORWARDS,
99+
val orderBy: MessageOrder = MessageOrder.NewestFirst,
98100
) {
99101
/**
100102
* Represents direction to query messages in.
101103
*/
102-
enum class Direction {
104+
enum class MessageOrder {
103105
/**
104106
* The response will include messages from the start of the time window to the end.
105107
*/
106-
FORWARDS,
108+
NewestFirst,
107109

108110
/**
109111
* the response will include messages from the end of the time window to the start.
110112
*/
111-
BACKWARDS,
113+
OldestFirst,
112114
}
113115
}
114116

chat-android/src/main/java/com/ably/chat/Occupancy.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ interface Occupancy : EmitsDiscontinuities {
2020
* Subscribe a given listener to occupancy updates of the chat room.
2121
*
2222
* @param listener A listener to be called when the occupancy of the room changes.
23-
* @returns A promise resolves to the channel attachment state change event from the implicit channel attach operation.
2423
*/
2524
fun subscribe(listener: Listener)
2625

@@ -34,7 +33,7 @@ interface Occupancy : EmitsDiscontinuities {
3433
/**
3534
* Get the current occupancy of the chat room.
3635
*
37-
* @returns A promise that resolves to the current occupancy of the chat room.
36+
* @returns the current occupancy of the chat room.
3837
*/
3938
suspend fun get(): OccupancyEvent
4039

0 commit comments

Comments
 (0)