aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-06-28 15:27:15 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:53 +0300
commite1644f8dc734b81b1faf3b3f4488c70e28ef1c21 (patch)
tree54bcaf47e6a030ef75a4749d49338229c1755f3e
parentc8406a729b849c22b5e1fb707cdee45bfad7c402 (diff)
accept text for Post and MessageInput
-rw-r--r--vnext/src/components/Message.js4
-rw-r--r--vnext/src/components/MessageInput.js5
-rw-r--r--vnext/src/components/Post.js6
3 files changed, 9 insertions, 6 deletions
diff --git a/vnext/src/components/Message.js b/vnext/src/components/Message.js
index e9d3eebd..585ae1ac 100644
--- a/vnext/src/components/Message.js
+++ b/vnext/src/components/Message.js
@@ -51,13 +51,13 @@ export default function Message(props) {
<span>&nbsp;Recommend</span>
</a>
) : visitor.uid > 0 ? (
- <a href="/post?body=!+%23{{ msg.mid }}" className="a-like msg-button">
+ <Link to={{pathname: "/post", search: `?body=!+%23${msg.mid}`}} className="a-like msg-button">
<span className="msg-button-icon">
<Icon name="ei-heart" size="s" />
{msg.likes > 0 && (` ${msg.likes}`)}
</span>
<span>&nbsp;Recommend</span>
- </a>
+ </Link>
) : (
<a href="/login" className="a-login msg-button">
<span className="msg-button-icon">
diff --git a/vnext/src/components/MessageInput.js b/vnext/src/components/MessageInput.js
index 5ef654a8..5d603a4b 100644
--- a/vnext/src/components/MessageInput.js
+++ b/vnext/src/components/MessageInput.js
@@ -16,7 +16,7 @@ export default class MessageInput extends React.Component {
mid: this.props.data.mid,
rid: this.props.data.rid || 0,
to: this.props.data.to || {},
- body: '',
+ body: this.props.text || '',
attach: ''
}
}
@@ -131,5 +131,6 @@ const textInputStyle = {
MessageInput.propTypes = {
data: MessageType.isRequired,
onSend: PropTypes.func.isRequired,
- rows: PropTypes.string
+ rows: PropTypes.string,
+ text: PropTypes.string
}; \ No newline at end of file
diff --git a/vnext/src/components/Post.js b/vnext/src/components/Post.js
index fd577603..7bde7432 100644
--- a/vnext/src/components/Post.js
+++ b/vnext/src/components/Post.js
@@ -1,4 +1,5 @@
import React from 'react';
+import * as qs from 'query-string';
import MessageInput from './MessageInput';
@@ -7,9 +8,10 @@ import { post } from '../api';
export default class Post extends React.Component {
constructor(props) {
super(props)
+ let params = qs.parse(window.location.search);
this.state = {
attach: '',
- body: ''
+ body: params.body || ''
}
this.fileinput = React.createRef();
console.log(props)
@@ -39,7 +41,7 @@ export default class Post extends React.Component {
render() {
return (
<article>
- <MessageInput rows="7" data={{ mid: 0, timestamp: "0" }} onSend={this.postMessage}>
+ <MessageInput rows="7" text={this.state.body} data={{ mid: 0, timestamp: "0" }} onSend={this.postMessage}>
*weather It's very cold today!
</MessageInput>
</article>