UNPKG

@cometchat/chat-uikit-react-native

Version:

Ready-to-use Chat UI Components for React Native

40 lines (37 loc) 1.48 kB
//@ts-ignore import { CometChat } from "@cometchat/chat-sdk-react-native"; import { MessageTypeConstants } from "../../../constants/UIKitConstants"; /** * Represents a custom interactive message that extends CometChat's InteractiveMessage class. * @extends CometChat.InteractiveMessage */ export class CustomInteractiveMessage extends CometChat.InteractiveMessage { /** * Creates a new instance of CustomInteractiveMessage. * @param receiverId - The ID of the receiver of the message. * @param receiverType - The type of the receiver of the message. * @param json - The JSON object to create the CustomInteractiveMessage object from. */ constructor( receiverId: string, receiverType: string, json: Object ) { super(receiverId, receiverType, MessageTypeConstants.customInteractive, json); } /** * Static method to create a CustomInteractiveMessage object from a JSON object. * @param json - JSON object to create the CustomInteractiveMessage object from. * @returns CustomInteractiveMessage object. */ static fromJSON(json: any): CustomInteractiveMessage { const data = json?.data?.interactiveData; const customInteractiveMessage = new CustomInteractiveMessage( json.receiverId, json.receiverType, data ); Object.assign(customInteractiveMessage, json); return customInteractiveMessage; } }