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
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
52f73c30ca
Коммит
69f3f2fdce
@@ -4,7 +4,6 @@
|
||||
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
|
||||
import EventEmitter from 'events';
|
||||
|
||||
import ChannelStore from 'stores/channel_store.jsx';
|
||||
import BrowserStore from 'stores/browser_store.jsx';
|
||||
import UserStore from 'stores/user_store.jsx';
|
||||
|
||||
@@ -17,6 +16,7 @@ const EDIT_POST_EVENT = 'edit_post';
|
||||
const POSTS_VIEW_JUMP_EVENT = 'post_list_jump';
|
||||
const SELECTED_POST_CHANGE_EVENT = 'selected_post_change';
|
||||
const POST_PINNED_CHANGE_EVENT = 'post_pinned_change';
|
||||
const POST_DRAFT_CHANGE_EVENT = 'post_draft_change';
|
||||
|
||||
class PostStoreClass extends EventEmitter {
|
||||
constructor() {
|
||||
@@ -75,6 +75,18 @@ class PostStoreClass extends EventEmitter {
|
||||
this.removeListener(POSTS_VIEW_JUMP_EVENT, callback);
|
||||
}
|
||||
|
||||
emitPostDraftChange(channelId) {
|
||||
this.emit(POST_DRAFT_CHANGE_EVENT + channelId, this.getPostDraft(channelId));
|
||||
}
|
||||
|
||||
addPostDraftChangeListener(channelId, callback) {
|
||||
this.on(POST_DRAFT_CHANGE_EVENT + channelId, callback);
|
||||
}
|
||||
|
||||
removePostDraftChangeListener(channelId, callback) {
|
||||
this.removeListener(POST_DRAFT_CHANGE_EVENT + channelId, callback);
|
||||
}
|
||||
|
||||
jumpPostsViewToBottom() {
|
||||
this.emitPostsViewJump(Constants.PostsViewJumpTypes.BOTTOM, null);
|
||||
}
|
||||
@@ -585,21 +597,11 @@ class PostStoreClass extends EventEmitter {
|
||||
return draft;
|
||||
}
|
||||
|
||||
storeCurrentDraft(draft) {
|
||||
var channelId = ChannelStore.getCurrentId();
|
||||
storePostDraft(channelId, draft) {
|
||||
BrowserStore.setGlobalItem('draft_' + channelId, draft);
|
||||
}
|
||||
|
||||
getCurrentDraft() {
|
||||
var channelId = ChannelStore.getCurrentId();
|
||||
return this.getDraft(channelId);
|
||||
}
|
||||
|
||||
storeDraft(channelId, draft) {
|
||||
BrowserStore.setGlobalItem('draft_' + channelId, draft);
|
||||
}
|
||||
|
||||
getDraft(channelId) {
|
||||
getPostDraft(channelId) {
|
||||
return this.normalizeDraft(BrowserStore.getGlobalItem('draft_' + channelId));
|
||||
}
|
||||
|
||||
@@ -700,7 +702,7 @@ PostStore.dispatchToken = AppDispatcher.register((payload) => {
|
||||
break;
|
||||
case ActionTypes.CREATE_POST:
|
||||
PostStore.storePendingPost(action.post);
|
||||
PostStore.storeDraft(action.post.channel_id, null);
|
||||
PostStore.storePostDraft(action.post.channel_id, null);
|
||||
PostStore.jumpPostsViewToBottom();
|
||||
break;
|
||||
case ActionTypes.CREATE_COMMENT:
|
||||
@@ -723,6 +725,10 @@ PostStore.dispatchToken = AppDispatcher.register((payload) => {
|
||||
case ActionTypes.RECEIVED_POST_UNPINNED:
|
||||
PostStore.emitPostPinnedChange();
|
||||
break;
|
||||
case ActionTypes.POST_DRAFT_CHANGED:
|
||||
PostStore.storePostDraft(action.channelId, action.draft);
|
||||
PostStore.emitPostDraftChange(action.channelId);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
});
|
||||
|
||||
Ссылка в новой задаче
Block a user