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

40 lines
792 B
JavaScript

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 [, secondBlock] = blocks;
const { appId = '' } = secondBlock;
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;