summaryrefslogtreecommitdiffstats
path: root/webapp/components/create_post.jsx
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-10-31 10:52:00 -0400
committerChristopher Speller <crspeller@gmail.com>2016-10-31 10:52:00 -0400
commita8e772fa4878e3004e5399d85b7105dee3859312 (patch)
treeb187a45ba263940f70115979bd0a198a148bb1ca /webapp/components/create_post.jsx
parentb3044ba4eaf017486f70c7f324d0942c37f71e28 (diff)
downloadchat-a8e772fa4878e3004e5399d85b7105dee3859312.tar.gz
chat-a8e772fa4878e3004e5399d85b7105dee3859312.tar.bz2
chat-a8e772fa4878e3004e5399d85b7105dee3859312.zip
Cleaned up code for ensuring post drafts are non-null (#4382)
Diffstat (limited to 'webapp/components/create_post.jsx')
-rw-r--r--webapp/components/create_post.jsx24
1 files changed, 2 insertions, 22 deletions
diff --git a/webapp/components/create_post.jsx b/webapp/components/create_post.jsx
index ae25fc74e..e7bf2b92a 100644
--- a/webapp/components/create_post.jsx
+++ b/webapp/components/create_post.jsx
@@ -40,7 +40,6 @@ export default class CreatePost extends React.Component {
this.lastTime = 0;
- this.getCurrentDraft = this.getCurrentDraft.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.postMsgKeyPress = this.postMsgKeyPress.bind(this);
this.handleChange = this.handleChange.bind(this);
@@ -61,7 +60,7 @@ export default class CreatePost extends React.Component {
PostStore.clearDraftUploads();
- const draft = this.getCurrentDraft();
+ const draft = PostStore.getCurrentDraft();
this.state = {
channelId: ChannelStore.getCurrentId(),
@@ -77,25 +76,6 @@ export default class CreatePost extends React.Component {
};
}
- getCurrentDraft() {
- const draft = PostStore.getCurrentDraft();
- const safeDraft = {fileInfos: [], messageText: '', uploadsInProgress: []};
-
- if (draft) {
- if (draft.message) {
- safeDraft.messageText = draft.message;
- }
- if (draft.fileInfos) {
- safeDraft.fileInfos = draft.fileInfos;
- }
- if (draft.uploadsInProgress) {
- safeDraft.uploadsInProgress = draft.uploadsInProgress;
- }
- }
-
- return safeDraft;
- }
-
handleSubmit(e) {
e.preventDefault();
@@ -358,7 +338,7 @@ export default class CreatePost extends React.Component {
onChange() {
const channelId = ChannelStore.getCurrentId();
if (this.state.channelId !== channelId) {
- const draft = this.getCurrentDraft();
+ const draft = PostStore.getCurrentDraft();
this.setState({channelId, messageText: draft.messageText, initialText: draft.messageText, submitting: false, serverError: null, postError: null, fileInfos: draft.fileInfos, uploadsInProgress: draft.uploadsInProgress});
}