Commit 0796525b authored by Tim Zallmann's avatar Tim Zallmann

Merge branch '35900-update-adddiscussioncomment-to-respect-immutable-pattern' into 'master'

Update addDiscussionComment to respect immutable pattern

See merge request gitlab-org/gitlab!19804
parents 0821434b c7f4d1b3
......@@ -74,23 +74,45 @@ export default {
data.design.discussions,
this.discussion.id,
);
currentDiscussion.node.notes.edges = [
...currentDiscussion.node.notes.edges,
{
__typename: 'NoteEdge',
node: createNote.note,
const updatedDiscussion = {
...currentDiscussion,
node: {
...currentDiscussion.node,
notes: {
...currentDiscussion.node.notes,
edges: [
...currentDiscussion.node.notes.edges,
{ __typename: 'NoteEdge', node: createNote.note },
],
},
},
];
};
store.writeQuery({
query: getDesignQuery,
data: {
...data,
design: {
...data.design,
notesCount: data.design.notesCount + 1,
const currentDiscussionIndex = data.design.discussions.edges.indexOf(currentDiscussion);
const payload = {
...data,
design: {
...data.design,
discussions: {
...data.design.discussions,
edges: [
...data.design.discussions.edges.slice(0, currentDiscussionIndex),
updatedDiscussion,
...data.design.discussions.edges.slice(
currentDiscussionIndex + 1,
data.design.discussions.edges.length,
),
],
},
notesCount: data.design.notesCount + 1,
},
};
store.writeQuery({
query: getDesignQuery,
data: payload,
});
},
onDone() {
......
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