Commit 8f15cabc authored by Tom Quirk's avatar Tom Quirk

Fix inability to add comments to a discussion

This.discussion.id was undefined in `cache_update`,
and so this is now passed in as a param to the update fn.
parent d2f99986
......@@ -71,7 +71,13 @@ export default {
data: { createNote },
},
) {
updateStoreAfterAddDiscussionComment(store, createNote, getDesignQuery, this.designVariables);
updateStoreAfterAddDiscussionComment(
store,
createNote,
getDesignQuery,
this.designVariables,
this.discussion.id,
);
},
onDone() {
this.discussionComment = '';
......
......@@ -45,14 +45,14 @@ const addNewVersionToStore = (store, query, version) => {
});
};
const addDiscussionCommentToStore = (store, createNote, query, queryVariables) => {
const addDiscussionCommentToStore = (store, createNote, query, queryVariables, discussionId) => {
const data = store.readQuery({
query,
variables: queryVariables,
});
const design = extractDesign(data);
const currentDiscussion = extractCurrentDiscussion(design.discussions, this.discussion.id);
const currentDiscussion = extractCurrentDiscussion(design.discussions, discussionId);
currentDiscussion.node.notes.edges = [
...currentDiscussion.node.notes.edges,
{
......@@ -186,11 +186,17 @@ export const updateStoreAfterDesignsDelete = (store, data, query, designs) => {
}
};
export const updateStoreAfterAddDiscussionComment = (store, data, query, queryVariables) => {
export const updateStoreAfterAddDiscussionComment = (
store,
data,
query,
queryVariables,
discussionId,
) => {
if (data.errors) {
onError(data, ADD_DISCUSSION_COMMENT_ERROR);
} else {
addDiscussionCommentToStore(store, data, query, queryVariables);
addDiscussionCommentToStore(store, data, query, queryVariables, discussionId);
}
};
......
---
title: Fix inability to add comments to a discussion in Design Management
merge_request: 21229
author:
type: fixed
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment