Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function () {
type ActionItem = [string, Typings.Action.MoreBoard.GeneralResult, number];
const moreboardActions: ActionItem[] = [
['photo', StandardMessage.MoreBoard.takePhoto, IMConstant.MessageType.image],
['camera', StandardMessage.MoreBoard.takeCamera, IMConstant.MessageType.image],
['video', StandardMessage.MoreBoard.takeVideo, IMConstant.MessageType.video],
['location', StandardMessage.MoreBoard.chooseLocation, IMConstant.MessageType.location],
];
moreboardActions.forEach(([action, handle, messageType]) => {
Model.Action.MoreBoard.registerDefault(action, {...handle, messageType});
});
// 默认值设置
Delegate.component.MoreBoard.defaultProps.getItems = () =>
['photo', 'camera', 'video', 'location'];
}
export default function () {
type ActionItem = [string, Typings.Action.MoreBoard.GeneralResult, number];
const moreboardActions: ActionItem[] = [
['photo', StandardMessage.MoreBoard.takePhoto, IMConstant.MessageType.image],
['camera', StandardMessage.MoreBoard.takeCamera, IMConstant.MessageType.image],
['video', StandardMessage.MoreBoard.takeVideo, IMConstant.MessageType.video],
['location', StandardMessage.MoreBoard.chooseLocation, IMConstant.MessageType.location],
];
moreboardActions.forEach(([action, handle, messageType]) => {
Model.Action.MoreBoard.registerDefault(action, {...handle, messageType});
});
// 默认值设置
Delegate.component.MoreBoard.defaultProps.getItems = () =>
['photo', 'camera', 'video', 'location'];
}
export function setup() {
setup_parse_action();
setup_display_action();
setup_abstract_action();
setup_moreboard_action();
setup_send_action();
setup_im_conversation_delegate();
setup_im_group_delegate();
// 代理设置
Delegate.config.messageType.text = EMSDK.IMConstant.MessageType.text;
Delegate.config.messageType.voice = EMSDK.IMConstant.MessageType.voice;
Delegate.config.messageType.system = EMSDK.IMConstant.MessageType.command;
}
export function setup() {
setup_parse_action();
setup_display_action();
setup_abstract_action();
setup_moreboard_action();
setup_send_action();
setup_im_conversation_delegate();
setup_im_group_delegate();
// 代理设置
Delegate.config.messageType.text = EMSDK.IMConstant.MessageType.text;
Delegate.config.messageType.voice = EMSDK.IMConstant.MessageType.voice;
Delegate.config.messageType.system = EMSDK.IMConstant.MessageType.command;
}
Delegate.im.conversation.deleteOne = (imId) => {
return ChatManager.deleteConversation(imId);
};
// TODO updateConfig
Delegate.im.conversation.markAllRead = (imId, chatType) => {
return ChatManager.markAllMessagesAsRead(imId, chatType);
};
// TODO markLatestUnread
export default function () {
const displayActions = [
[[], StandardMessage.Display.GeneralBubble],
[IMConstant.MessageType.text, StandardMessage.Display.TextBubble],
[IMConstant.MessageType.image, StandardMessage.Display.ImageBubble],
[IMConstant.MessageType.location, StandardMessage.Display.LocationBubble],
[IMConstant.MessageType.video, StandardMessage.Display.VideoBubble],
[IMConstant.MessageType.voice, StandardMessage.Display.VoiceBubble],
];
displayActions.forEach(function ([messageType, handleFunc]) {
Model.Action.Display.registerDefault(messageType, handleFunc);
});
}
export default function () {
const abstractActions = [
[[], () => ''],
[IMConstant.MessageType.text, StandardMessage.Abstract.TextAbstract],
[IMConstant.MessageType.image, StandardMessage.Abstract.ImageAbstract],
[IMConstant.MessageType.location, StandardMessage.Abstract.LocationAbstract],
[IMConstant.MessageType.video, StandardMessage.Abstract.VideoAbstract],
[IMConstant.MessageType.voice, StandardMessage.Abstract.VoiceAbstract],
[IMConstant.MessageType.file, StandardMessage.Abstract.FileAbstract],
];
abstractActions.forEach(function ([messageType, abstractFunc]) {
Model.Action.Abstract.registerDefault(messageType, abstractFunc);
});
}
export default function () {
type ActionItem = [
number,
(params: Typings.Action.Send.Params) => Typings.Action.Send.Result
];
const sendActions: ActionItem[] = [
[IMConstant.MessageType.text, sendText],
[IMConstant.MessageType.image, sendImage],
[IMConstant.MessageType.location, sendLocation],
[IMConstant.MessageType.video, sendVideo],
[IMConstant.MessageType.voice, sendVoice],
[IMConstant.MessageType.file, sendFile],
];
sendActions.forEach(([type, func]) => {
Model.Action.Send.registerSpecial(
type,
(_?: Typings.Action.Send.State) => true,
func,
Specials.PRIORITY.LOW
);
});
}
const images = messages.filter(({type}) => type === IMConstant.MessageType.image).reverse();
const currentIndex = images.findIndex(image => image.messageId === messageId);