Report typing status
Report the current user’s typing status with the WASM SDK.
Pass focus: true when the user starts typing. Pass false after sending a message, when the input loses focus, when switching conversations, or when the user stops typing. Typing status is associated with conversationID; it neither saves a draft nor writes to the message list.
await openimsdk.changeInputStates({ conversationID, focus: true });
// When the user stops typing:
await openimsdk.changeInputStates({ conversationID, focus: false });Throttle the start-typing report and deduplicate state changes instead of reporting on every keyboard event. Promise completion means only that the server accepted the request; it does not mean a remote interface has already updated.
This page is the sole owner of CbEvents.OnConversationUserInputStatusChanged. Use a stable handler reference, and replace the platformIDs snapshot by conversationID:userID:
import { CbEvents } from '@openim/wasm-client-sdk';
const handleInputStatusChanged = ({ data }) => {
updateTypingState(data.conversationID, data.userID, data.platformIDs);
};
openimsdk.on(CbEvents.OnConversationUserInputStatusChanged, handleInputStatusChanged);
function removeInputStatusListener() {
openimsdk.off(CbEvents.OnConversationUserInputStatusChanged, handleInputStatusChanged);
}Was this page helpful?