2020-02-11 14:01:35 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { messageBlockWithContext } from '../UIKit/MessageBlock';
|
|
|
|
|
2021-07-23 01:59:16 +00:00
|
|
|
export interface IMessageBlocks {
|
2021-07-22 20:09:06 +00:00
|
|
|
blocks: any;
|
|
|
|
id: string;
|
|
|
|
rid: string;
|
|
|
|
blockAction: Function;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Blocks = React.memo(({ blocks, id: mid, rid, blockAction }: IMessageBlocks) => {
|
2020-02-11 14:01:35 +00:00
|
|
|
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({
|
2021-07-22 20:09:06 +00:00
|
|
|
action: async({ actionId, value, blockId }: any) => {
|
2020-02-11 14:01:35 +00:00
|
|
|
await blockAction({
|
|
|
|
actionId,
|
|
|
|
appId,
|
|
|
|
value,
|
|
|
|
blockId,
|
|
|
|
rid,
|
|
|
|
mid
|
|
|
|
});
|
|
|
|
},
|
|
|
|
appId,
|
|
|
|
rid
|
|
|
|
}), { blocks }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
});
|
|
|
|
|
|
|
|
Blocks.displayName = 'MessageBlocks';
|
|
|
|
|
|
|
|
export default Blocks;
|