if (!context.accountId) { return ""; } const item = props.item; if (!context.accountId) { return ""; } const composeData = () => { const data = { post: { comment: JSON.stringify(Object.assign({ item }, state.content)), }, index: { comment: JSON.stringify({ key: item, value: { type: "md", }, }), }, }; const notifications = state.extractTagNotifications(state.content.text, { type: "social", path: `${context.accountId}/post/main`, }); if (props.notifyAccountId) { notifications.push({ key: props.notifyAccountId, value: { type: "comment", item, }, }); } if (notifications.length) { data.index.notify = JSON.stringify( notifications.length > 1 ? notifications : notifications[0] ); } return data; }; State.init({ onChange: ({ content }) => { State.update({ content }); }, }); return ( <> <Widget src="mob.near/widget/Common.Compose" props={{ placeholder: "Reply", onChange: state.onChange, onHelper: ({ extractTagNotifications }) => { State.update({ extractTagNotifications }); }, composeButton: (onCompose) => ( <CommitButton disabled={!state.content} force className="btn btn-dark rounded-3" data={composeData} onCommit={() => { onCompose(); props.onComment && props.onComment(state.content); }} > Comment </CommitButton> ), }} /> {state.content && ( <div className="mt-3"> <Widget src="mob.near/widget/MainPage.Comment" props={{ item, accountId: context.accountId, content: state.content, blockHeight: "now", }} /> </div> )} </> );