Skip to content

Commit

Permalink
feat: add new input state api (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bloomingg authored Oct 16, 2024
1 parent 2e351cb commit 59780a8
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openim/wasm-client-sdk",
"version": "3.8.2",
"version": "3.8.2-1",
"description": "open im sdk for web",
"source": "src/index.ts",
"main": "lib/index.js",
Expand Down
3 changes: 3 additions & 0 deletions src/constant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ export enum CbEvents {
OnProgress = 'OnProgress',
OnRecvNewMessage = 'OnRecvNewMessage',
OnRecvNewMessages = 'OnRecvNewMessages',
OnRecvOnlineOnlyMessage = 'OnRecvOnlineOnlyMessage',
OnRecvOfflineNewMessage = 'onRecvOfflineNewMessage',
OnRecvOnlineOnlyMessages = 'OnRecvOnlineOnlyMessages',
OnRecvOfflineNewMessages = 'onRecvOfflineNewMessages',
OnRecvMessageRevoked = 'OnRecvMessageRevoked',
OnNewRecvMessageRevoked = 'OnNewRecvMessageRevoked',
OnRecvC2CReadReceipt = 'OnRecvC2CReadReceipt',
OnRecvGroupReadReceipt = 'OnRecvGroupReadReceipt',
OnConversationChanged = 'OnConversationChanged',
OnNewConversation = 'OnNewConversation',
OnConversationUserInputStatusChanged = 'OnConversationUserInputStatusChanged',
OnSyncServerFailed = 'OnSyncServerFailed',
OnSyncServerFinish = 'OnSyncServerFinish',
OnSyncServerProgress = 'OnSyncServerProgress',
Expand Down
29 changes: 28 additions & 1 deletion src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ import {
UpdateFriendsParams,
SetConversationParams,
GetSpecifiedFriendsParams,
ChangeInputStatesParams,
GetInputstatesParams,
} from '../types/params';

import {
Expand All @@ -97,7 +99,12 @@ import {
WSEvent,
WsResponse,
} from '../types/entity';
import { GroupAtType, LoginStatus, MessageReceiveOptType } from '@/types/enum';
import {
GroupAtType,
LoginStatus,
MessageReceiveOptType,
Platform,
} from '@/types/enum';
import { logBoxStyleValue } from '@/utils';
class SDK extends Emitter {
private wasmInitializedPromise: Promise<any>;
Expand Down Expand Up @@ -891,6 +898,9 @@ class SDK extends Emitter {
[operationID, JSON.stringify(data.message), data.groupID, data.sendID]
);
};
/**
* @deprecated Use changeInputStates instead.
*/
typingStatusUpdate = <T>(
data: TypingUpdateParams,
operationID = uuidv4()
Expand All @@ -901,6 +911,23 @@ class SDK extends Emitter {
data.msgTip,
]);
};
changeInputStates = (
data: ChangeInputStatesParams,
operationID = uuidv4()
) => {
return this._invoker<void>('changeInputStates ', window.changeInputStates, [
operationID,
data.conversationID,
data.focus,
]);
};
getInputstates = (data: GetInputstatesParams, operationID = uuidv4()) => {
return this._invoker<Platform[]>('getInputstates ', window.getInputstates, [
operationID,
data.conversationID,
data.userID,
]);
};
clearConversationAndDeleteAllMsg = <T>(
data: string,
operationID = uuidv4()
Expand Down
6 changes: 6 additions & 0 deletions src/types/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,12 @@ export type UserOnlineState = {
userID: string;
};

export type ConversationInputStatus = {
conversationID: string;
userID: string;
platformIDs: Platform[];
};

export type GroupMessageReceiptInfo = {
conversationID: string;
groupMessageReadInfo: GroupMessageReadInfo[];
Expand Down
4 changes: 4 additions & 0 deletions src/types/eventData.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CbEvents } from '..';
import {
BlackUserItem,
ConversationInputStatus,
ConversationItem,
FriendApplicationItem,
FriendUserItem,
Expand Down Expand Up @@ -36,13 +37,16 @@ export type EventDataMap = {
[CbEvents.OnJoinedGroupAdded]: GroupItem;
[CbEvents.OnJoinedGroupDeleted]: GroupItem;
[CbEvents.OnNewConversation]: ConversationItem[];
[CbEvents.OnConversationUserInputStatusChanged]: ConversationInputStatus;
[CbEvents.OnNewRecvMessageRevoked]: RevokedInfo;
[CbEvents.OnRecvC2CReadReceipt]: ReceiptInfo[];
[CbEvents.OnRecvGroupReadReceipt]: GroupMessageReceiptInfo;
[CbEvents.OnRecvNewMessage]: MessageItem;
[CbEvents.OnRecvNewMessages]: MessageItem[];
[CbEvents.OnRecvOfflineNewMessage]: MessageItem;
[CbEvents.OnRecvOnlineOnlyMessage]: MessageItem;
[CbEvents.OnRecvOfflineNewMessages]: MessageItem[];
[CbEvents.OnRecvOnlineOnlyMessages]: MessageItem[];
[CbEvents.OnSelfInfoUpdated]: SelfUserInfo;
[CbEvents.OnSyncServerFailed]: void;
[CbEvents.OnSyncServerStart]: boolean;
Expand Down
11 changes: 11 additions & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Platform } from './enum';
import { CreateGroupParams } from './params';

type DatabaseApi = (...args: any[]) => Promise<any>;
Expand Down Expand Up @@ -512,6 +513,16 @@ declare global {
recvID: string,
msgTip: string
) => Promise<string>;
changeInputStates: (
operationID: string,
conversationID: string,
focus: boolean
) => Promise<void>;
getInputstates: (
operationID: string,
conversationID: string,
userID: string
) => Promise<Platform[]>;
markNotifyMessageHasRead: (
operationID: string,
conversationID: string
Expand Down
8 changes: 8 additions & 0 deletions src/types/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,14 @@ export type TypingUpdateParams = {
recvID: string;
msgTip: string;
};
export type ChangeInputStatesParams = {
conversationID: string;
focus: boolean;
};
export type GetInputstatesParams = {
conversationID: string;
userID: string;
};
export type SetConversationExParams = {
conversationID: string;
ex: string;
Expand Down

0 comments on commit 59780a8

Please sign in to comment.