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 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);
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
);
});
}
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);
});
}
function convertLocation(message: Typings.Message.Origin) {
return convertBasicMessage(
message,
IMConstant.MessageType.location,
{
latitude: message.body.latitude,
longitude: message.body.longitude,
address: message.body.address,
name: message.ext ? message.ext.name : '',
}
);
}
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);
});
}