diff --git a/.pubnub.yml b/.pubnub.yml index 83f6aad..1b9f6f9 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,11 +1,16 @@ --- name: pubnub-js-chat -version: v0.8.1 +version: v0.8.2 scm: github.com/pubnub/js-chat schema: 1 files: - lib/dist/index.js changelog: + - date: 2024-08-27 + version: v0.8.2 + changes: + - type: feature + text: "Customize message reactions." - date: 2024-08-01 version: v0.8.1 changes: diff --git a/lib/package.json b/lib/package.json index 3c9ca2b..e17101a 100644 --- a/lib/package.json +++ b/lib/package.json @@ -1,6 +1,6 @@ { "name": "@pubnub/chat", - "version": "0.8.1", + "version": "0.8.2", "description": "PubNub JavaScript Chat SDK", "author": "PubNub ", "license": "SEE LICENSE IN LICENSE", diff --git a/lib/src/default-values.ts b/lib/src/default-values.ts index a0e4dc6..0de4805 100644 --- a/lib/src/default-values.ts +++ b/lib/src/default-values.ts @@ -21,3 +21,5 @@ export function defaultGetMessageResponseBody(messageParams: MessageDTOParams) { export const defaultEditActionName = MessageActionType.EDITED export const defaultDeleteActionName = MessageActionType.DELETED + +export const defaultReactionsName = MessageActionType.REACTIONS diff --git a/lib/src/entities/chat.ts b/lib/src/entities/chat.ts index 4449580..0975b40 100644 --- a/lib/src/entities/chat.ts +++ b/lib/src/entities/chat.ts @@ -22,7 +22,11 @@ import { MessageElementsUtils } from "../message-elements-utils" import { getErrorProxiedEntity, ErrorLogger } from "../error-logging" import { cyrb53a } from "../hash" import { uuidv4 } from "../uuidv4" -import { defaultEditActionName, defaultDeleteActionName } from "../default-values" +import { + defaultEditActionName, + defaultDeleteActionName, + defaultReactionsName, +} from "../default-values" import { AccessManager } from "../access-manager" export type ChatConfig = { @@ -47,6 +51,7 @@ export type ChatConfig = { getMessageResponseBody?: (m: MessageDTOParams) => TextMessageContent editMessageActionName?: string deleteMessageActionName?: string + reactionsActionName?: string } authKey?: string } @@ -72,6 +77,8 @@ export class Chat { /** @internal */ readonly deleteMessageActionName: string /** @internal */ + readonly reactionsActionName: string + /** @internal */ readonly accessManager: AccessManager /** @internal */ @@ -93,6 +100,7 @@ export class Chat { this.editMessageActionName = customPayloads?.editMessageActionName || defaultEditActionName this.deleteMessageActionName = customPayloads?.deleteMessageActionName || defaultDeleteActionName + this.reactionsActionName = customPayloads?.reactionsActionName || defaultReactionsName try { if (storeUserActivityInterval && storeUserActivityInterval < 60000) { diff --git a/lib/src/entities/message.ts b/lib/src/entities/message.ts index a4a231b..227c4a3 100644 --- a/lib/src/entities/message.ts +++ b/lib/src/entities/message.ts @@ -1,12 +1,6 @@ import { Chat } from "./chat" import PubNub from "pubnub" -import { - DeleteParameters, - MessageActions, - MessageDTOParams, - TextMessageContent, - MessageActionType, -} from "../types" +import { DeleteParameters, MessageActions, MessageDTOParams, TextMessageContent } from "../types" import { INTERNAL_ADMIN_CHANNEL, INTERNAL_MODERATION_PREFIX } from "../constants" import { getErrorProxiedEntity } from "../error-logging" import { MessageElementsUtils } from "../message-elements-utils" @@ -319,7 +313,7 @@ export class Message { * Reactions */ get reactions() { - const type = MessageActionType.REACTIONS + const type = this.chat.reactionsActionName return this.actions?.[type] || {} } @@ -328,7 +322,7 @@ export class Message { } async toggleReaction(reaction: string) { - const type = MessageActionType.REACTIONS + const type = this.chat.reactionsActionName const uuid = this.chat.sdk.getUUID() const messageTimetoken = this.timetoken const channel = this.channelId