Skip to main content

Editing Chat Messages

As mentioned in introduction, there are 3 types of chat messages - text messages, images, and files. There is a method in meeting.chat to edit a message of each type.

Edit a text message

To edit a text message, the meeting.chat.editTextMessage() method can be used. This accepts a messageId (type string) and a message (type string).

const message = meeting.chat.messages[0];
const messageId = message?.id;
const newMessage = 'Is this the real life?';
await meeting.chat.editTextMessage(messageId, newMessage);

Edit an image

You can send an image with the help of meeting.chat.editImageMessage(). This accepts a messageId of type string and an image of type File.

async function onEditImage() {
const messageId = '...';
// Get the image uri and create an object with the following fields
const res = await DocumentPicker.pickSingle({
type: [DocumentPicker.types.images],
});
const image = {
uri: res.uri,
name: res.name,
size: res.size,
type: res.type,
};
await meeting.chat.editImageMessage(messageId, image);
}

Edit a file

Editing a file is quite similar to editing an image. To edit a file use meeting.chat.editFileMessage().

async function onEditFile() {
const messageId = '...';
// Get the file uri and create an object with the following fields
const res = await DocumentPicker.pickSingle({
type: [DocumentPicker.types.allFiles],
});
const file = {
uri: res.uri,
name: res.name,
size: res.size,
type: res.type,
};
await meeting.chat.editFileMessage(messageId, file);
}

Extra

There is also a common method called meeting.chat.editMessage() that can be used to edit any of the 3 types of messages displayed above. It essentially calls one of the methods from above depending upon the type of payload you send to the method. The editMessage() method accepts a parameters messageId message of the following type:

async function editMessage(
messageId: string,
message: { type: 'text', message: string }
| { type: 'image', image: File }
| { type: 'file', file: File },
) {...}

Here's how you would use the editMessage() method to edit a text message.

const messageId = '...';
const message = 'Is this just fantasy?';
await meeting.chat.sendMessage(messageId, { type: 'text', message });