Rocket.Chat.ReactNative/app/containers/message/Blocks.js

39 lines
760 B
JavaScript
Raw Normal View History

2020-02-11 14:01:35 +00:00
import React from 'react';
import PropTypes from 'prop-types';
import { messageBlockWithContext } from '../UIKit/MessageBlock';
const Blocks = React.memo(({
blocks, id: mid, rid, blockAction
}) => {
if (blocks && blocks.length > 0) {
const appId = blocks[0]?.appId || '';
2020-02-11 14:01:35 +00:00
return React.createElement(
messageBlockWithContext({
action: async({ actionId, value, blockId }) => {
await blockAction({
actionId,
appId,
value,
blockId,
rid,
mid
});
},
appId,
rid
}), { blocks }
);
}
return null;
});
Blocks.propTypes = {
blocks: PropTypes.array,
id: PropTypes.string,
rid: PropTypes.string,
blockAction: PropTypes.func
};
Blocks.displayName = 'MessageBlocks';
export default Blocks;