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) {
|
2020-04-13 13:56:57 +00:00
|
|
|
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;
|