Fixed post draft selectors returning null (#932)
This commit is contained in:
parent
94714d638b
commit
05bfc04ec9
2 changed files with 18 additions and 2 deletions
|
|
@ -21,6 +21,10 @@ const checkForFileUploadingInChannel = createSelector(
|
|||
return state.views.channel.drafts[channelId];
|
||||
},
|
||||
(draft) => {
|
||||
if (!draft || !draft.files) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return draft.files.some((f) => f.loading);
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,15 @@
|
|||
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import {createSelector} from 'reselect';
|
||||
|
||||
import {getCurrentChannel} from 'mattermost-redux/selectors/entities/channels';
|
||||
|
||||
const emptyDraft = {
|
||||
draft: '',
|
||||
files: []
|
||||
};
|
||||
|
||||
function getChannelDrafts(state) {
|
||||
return state.views.channel.drafts;
|
||||
}
|
||||
|
|
@ -13,11 +21,15 @@ function getThreadDrafts(state) {
|
|||
export const getCurrentChannelDraft = createSelector(
|
||||
getChannelDrafts,
|
||||
getCurrentChannel,
|
||||
(drafts, currentChannel) => drafts[currentChannel.id]
|
||||
(drafts, currentChannel) => {
|
||||
return drafts[currentChannel.id] || emptyDraft;
|
||||
}
|
||||
);
|
||||
|
||||
export const getThreadDraft = createSelector(
|
||||
getThreadDrafts,
|
||||
(state, rootId) => rootId,
|
||||
(drafts, rootId) => drafts[rootId]
|
||||
(drafts, rootId) => {
|
||||
return drafts[rootId] || emptyDraft;
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue