quick comment fix while waiting for release branch to be merged into master
This commit is contained in:
parent
4067e1ffd8
commit
799c0c1f11
3 changed files with 17 additions and 4 deletions
|
@ -11,9 +11,9 @@ const select = (state, props) => ({
|
|||
channels: selectMyChannelClaims(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
const perform = (dispatch, ownProps) => ({
|
||||
createComment: (comment, claimId, channel, parentId) =>
|
||||
dispatch(doCommentCreate(comment, claimId, channel, parentId)),
|
||||
dispatch(doCommentCreate(comment, claimId, channel, parentId, ownProps.uri)),
|
||||
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
|
||||
});
|
||||
|
||||
|
|
|
@ -39,7 +39,13 @@ export function doCommentList(uri: string, page: number = 1, pageSize: number =
|
|||
};
|
||||
}
|
||||
|
||||
export function doCommentCreate(comment: string = '', claim_id: string = '', channel: string, parent_id?: string) {
|
||||
export function doCommentCreate(
|
||||
comment: string = '',
|
||||
claim_id: string = '',
|
||||
channel: string,
|
||||
parent_id?: string,
|
||||
uri: string
|
||||
) {
|
||||
return (dispatch: Dispatch, getState: GetState) => {
|
||||
const state = getState();
|
||||
dispatch({
|
||||
|
@ -74,6 +80,7 @@ export function doCommentCreate(comment: string = '', claim_id: string = '', cha
|
|||
dispatch({
|
||||
type: ACTIONS.COMMENT_CREATE_COMPLETED,
|
||||
data: {
|
||||
uri,
|
||||
comment: result,
|
||||
claimId: claim_id,
|
||||
},
|
||||
|
|
|
@ -23,11 +23,12 @@ export default handleActions(
|
|||
}),
|
||||
|
||||
[ACTIONS.COMMENT_CREATE_COMPLETED]: (state: CommentsState, action: any): CommentsState => {
|
||||
const { comment, claimId }: { comment: Comment, claimId: string } = action.data;
|
||||
const { comment, claimId, uri }: { comment: Comment, claimId: string, uri: string } = action.data;
|
||||
const commentById = Object.assign({}, state.commentById);
|
||||
const byId = Object.assign({}, state.byId);
|
||||
const comments = byId[claimId] || [];
|
||||
const newCommentIds = comments.slice();
|
||||
const commentsByUri = Object.assign({}, state.commentsByUri);
|
||||
|
||||
// add the comment by its ID
|
||||
commentById[comment.comment_id] = comment;
|
||||
|
@ -36,10 +37,15 @@ export default handleActions(
|
|||
newCommentIds.unshift(comment.comment_id);
|
||||
byId[claimId] = newCommentIds;
|
||||
|
||||
if (!commentsByUri[uri]) {
|
||||
commentsByUri[uri] = claimId;
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
commentById,
|
||||
byId,
|
||||
commentsByUri,
|
||||
isLoading: false,
|
||||
};
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue