SDKsHarmonyOSEnterprise
Set conversation draft
Persist or clear in-progress message draft text for a specific conversation.
Debounce draft updates while the user types in the input editor, and commit the latest value when unmounting or navigating away from the chat screen:
Code example
import sdk, { SetConversationDraftReq } from '@openimsdk/imsdk';
const request: SetConversationDraftReq = {
conversationID: conversationID,
draftText: editorValue,
};
await sdk.setConversationDraft(request);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | string | Yes | Target conversation identifier. |
draftText | string | Yes | Draft text string. Pass an empty string to clear the saved draft. |
Return value
Returns a Promise that resolves to void when the draft is stored.
State changes after the call
Passing an empty string clears the active draft. After the Promise resolves, the SDK emits EventOnConversationChanged. Match the item by conversationID and update both draftText and draftTextTime in your conversation list model, as described in Retrieve conversation list. Clear in-memory editor buffers when signing out or switching accounts.
Was this page helpful?