Skip to content

Commit

Permalink
Add missing streamMessageReports method in JS (#170)
Browse files Browse the repository at this point in the history
* PubNub js 0.11.4 release.

---------

Co-authored-by: marcin.cebo <[email protected]>
Co-authored-by: PubNub Release Bot <[email protected]>
  • Loading branch information
3 people authored Feb 4, 2025
1 parent eeb86b9 commit 2c46f05
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SONATYPE_HOST=DEFAULT
SONATYPE_AUTOMATIC_RELEASE=false
GROUP=com.pubnub
POM_PACKAGING=jar
VERSION_NAME=0.11.3
VERSION_NAME=0.11.4

POM_NAME=PubNub Chat SDK
POM_DESCRIPTION=This SDK offers a set of handy methods to create your own feature-rich chat or add a chat to your existing application.
Expand Down
7 changes: 6 additions & 1 deletion js-chat/.pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
name: pubnub-js-chat
version: 0.11.3
version: 0.11.4
scm: github.com/pubnub/js-chat
schema: 1
files:
- lib/dist/index.js
changelog:
- date: 2025-02-04
version: 0.11.4
changes:
- type: bug
text: "Added missing streamMessageReports method in JS."
- date: 2025-01-30
version: 0.11.3
changes:
Expand Down
2 changes: 1 addition & 1 deletion js-chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"module": "dist/index.es.js",
"types": "dist/index.d.ts",
"react-native": "dist/index.es.js",
"version": "0.11.3",
"version": "0.11.4",
"name": "@pubnub/chat",
"dependencies": {
"pubnub": "8.6.0",
Expand Down
21 changes: 21 additions & 0 deletions js-chat/tests/channel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,27 @@ describe("Channel test", () => {
expect(errorOccurred).toBe(true)
})

test("streamMessageReport should receive reported message", async () => {
const messageTextToReport = "lalalal"
const reason = "rude";
let receivedEvent

const unsubscribe = channel.streamMessageReports((event) => {
receivedEvent = event
})

const { timetoken } = await channel.sendText(messageTextToReport);
await sleep(1000) // delayForHistory
const message = await channel.getMessage(timetoken);

await message.report(reason);
await sleep(500)

expect(receivedEvent.payload.text).toEqual(messageTextToReport);
expect(receivedEvent.payload.reason).toEqual(reason);
unsubscribe(); // Cleanup
});

test("should stream channel updates and invoke the callback", async () => {
let updatedChannel
channel = await channel.update({ type: "public" })
Expand Down
5 changes: 5 additions & 0 deletions pubnub-chat-impl/src/jsMain/kotlin/ChannelJs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ open class ChannelJs internal constructor(internal val channel: Channel, interna
}.asPromise()
}

fun streamMessageReports(callback: (EventJs) -> Unit): () -> Unit =
channel.streamMessageReports { event ->
callback(event.toJs(chatJs))
}::close

@Deprecated("Only for internal MessageDraft V1 use")
fun getUserSuggestions(text: String, options: GetSuggestionsParams?): Promise<Array<MembershipJs>> {
val limit = options?.limit
Expand Down

0 comments on commit 2c46f05

Please sign in to comment.