diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2017-05-23 10:17:06 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-23 10:17:06 -0400 |
commit | 69f3f2fdce4ae21a037ca61d753279efcc70f0ec (patch) | |
tree | dea69385c8bd3190d7bc2f72563b929ecdf527f2 /webapp/components/create_post.jsx | |
parent | 52f73c30cafd6afaa11361b05972e25ebc223a81 (diff) | |
download | chat-69f3f2fdce4ae21a037ca61d753279efcc70f0ec.tar.gz chat-69f3f2fdce4ae21a037ca61d753279efcc70f0ec.tar.bz2 chat-69f3f2fdce4ae21a037ca61d753279efcc70f0ec.zip |
PLT-6282 Make post list stay visible when post textbox height changes (#6323)
* PLT-6282 Changed post drafts to use an action when being stored
* PLT-6282 Triggered post list to update scroll position when post draft changes
* PLT-6282 Changed SuggestionBox to complete suggestions without an event
Diffstat (limited to 'webapp/components/create_post.jsx')
-rw-r--r-- | webapp/components/create_post.jsx | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/webapp/components/create_post.jsx b/webapp/components/create_post.jsx index 6e59b88b1..59c12e059 100644 --- a/webapp/components/create_post.jsx +++ b/webapp/components/create_post.jsx @@ -71,10 +71,11 @@ export default class CreatePost extends React.Component { PostStore.clearDraftUploads(); - const draft = PostStore.getCurrentDraft(); + const channelId = ChannelStore.getCurrentId(); + const draft = PostStore.getPostDraft(channelId); this.state = { - channelId: ChannelStore.getCurrentId(), + channelId, message: draft.message, uploadsInProgress: draft.uploadsInProgress, fileInfos: draft.fileInfos, @@ -136,7 +137,7 @@ export default class CreatePost extends React.Component { const isReaction = REACTION_PATTERN.exec(post.message); if (post.message.indexOf('/') === 0) { - PostStore.storeDraft(this.state.channelId, null); + PostActions.storePostDraft(this.state.channelId, null); this.setState({message: '', postError: null, fileInfos: [], enableSendButton: false}); const args = {}; @@ -241,7 +242,7 @@ export default class CreatePost extends React.Component { PostActions.removeReaction(this.state.channelId, postId, emojiName); } - PostStore.storeCurrentDraft(null); + PostActions.storePostDraft(this.state.channelId, null); } focusTextbox(keepFocus = false) { @@ -271,9 +272,9 @@ export default class CreatePost extends React.Component { enableSendButton }); - const draft = PostStore.getCurrentDraft(); + const draft = PostStore.getPostDraft(this.state.channelId); draft.message = message; - PostStore.storeCurrentDraft(draft); + PostActions.storePostDraft(this.state.channelId, draft); } handleFileUploadChange() { @@ -281,10 +282,10 @@ export default class CreatePost extends React.Component { } handleUploadStart(clientIds, channelId) { - const draft = PostStore.getDraft(channelId); + const draft = PostStore.getPostDraft(channelId); draft.uploadsInProgress = draft.uploadsInProgress.concat(clientIds); - PostStore.storeDraft(channelId, draft); + PostActions.storePostDraft(channelId, draft); this.setState({uploadsInProgress: draft.uploadsInProgress}); @@ -294,7 +295,7 @@ export default class CreatePost extends React.Component { } handleFileUploadComplete(fileInfos, clientIds, channelId) { - const draft = PostStore.getDraft(channelId); + const draft = PostStore.getPostDraft(channelId); // remove each finished file from uploads for (let i = 0; i < clientIds.length; i++) { @@ -306,7 +307,7 @@ export default class CreatePost extends React.Component { } draft.fileInfos = draft.fileInfos.concat(fileInfos); - PostStore.storeDraft(channelId, draft); + PostActions.storePostDraft(channelId, draft); if (channelId === this.state.channelId) { this.setState({ @@ -325,14 +326,14 @@ export default class CreatePost extends React.Component { } if (clientId !== -1) { - const draft = PostStore.getDraft(channelId); + const draft = PostStore.getPostDraft(channelId); const index = draft.uploadsInProgress.indexOf(clientId); if (index !== -1) { draft.uploadsInProgress.splice(index, 1); } - PostStore.storeDraft(channelId, draft); + PostActions.storePostDraft(channelId, draft); if (channelId === this.state.channelId) { this.setState({uploadsInProgress: draft.uploadsInProgress}); @@ -362,10 +363,10 @@ export default class CreatePost extends React.Component { fileInfos.splice(index, 1); } - const draft = PostStore.getCurrentDraft(); + const draft = PostStore.getPostDraft(this.state.channelId); draft.fileInfos = fileInfos; draft.uploadsInProgress = uploadsInProgress; - PostStore.storeCurrentDraft(draft); + PostActions.storePostDraft(this.state.channelId, draft); const enableSendButton = this.handleEnableSendButton(this.state.message, fileInfos); this.setState({fileInfos, uploadsInProgress, enableSendButton}); @@ -432,7 +433,7 @@ export default class CreatePost extends React.Component { onChange() { const channelId = ChannelStore.getCurrentId(); if (this.state.channelId !== channelId) { - const draft = PostStore.getCurrentDraft(); + const draft = PostStore.getPostDraft(channelId); this.setState({channelId, message: draft.message, submitting: false, serverError: null, postError: null, fileInfos: draft.fileInfos, uploadsInProgress: draft.uploadsInProgress}); } @@ -453,7 +454,7 @@ export default class CreatePost extends React.Component { return this.state.fileInfos.length + this.state.uploadsInProgress.length; } - const draft = PostStore.getDraft(channelId); + const draft = PostStore.getPostDraft(channelId); return draft.fileInfos.length + draft.uploadsInProgress.length; } |