Update local message content
Replace full message contents directly within the local device database.
This operation modifies only the local message record on the current device. The API expects a complete IMMessage object rather than isolated partial fields.
Code example
import sdk, { IMMessage, SetMessageLocalContentReq } from '@openimsdk/imsdk';
const localMessage: IMMessage = cloneMessage(message);
if (localMessage.textElem !== undefined) {
localMessage.textElem.content = 'Device-local updated text';
}
const request: SetMessageLocalContentReq = {
conversationID: conversationID,
message: localMessage,
};
await sdk.setMessageLocalContent(request);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | string | Yes | Target conversation identifier. |
message | IMMessage | Yes | Complete message object with modified local contents. |
Return value
Returns a Promise that resolves to void when the local database write completes.
State changes after the call
In the example, cloneMessage represents a type-safe deep clone helper implemented by your application. The updated message object must preserve original keys and mandatory properties; do not pass an object containing only clientMsgID and partial content. Promise resolution does not upload modifications to OpenIMServer, synchronize to other devices, or fire shared message events. If you only need to store auxiliary application data like voice transcripts, saving them to local extensions via Set message local extension is usually preferable.
Was this page helpful?