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 { ...@@ -74,23 +74,45 @@ export default {
data.design.discussions, data.design.discussions,
this.discussion.id, this.discussion.id,
); );
currentDiscussion.node.notes.edges = [
...currentDiscussion.node.notes.edges, const updatedDiscussion = {
{ ...currentDiscussion,
__typename: 'NoteEdge', node: {
node: createNote.note, ...currentDiscussion.node,
notes: {
...currentDiscussion.node.notes,
edges: [
...currentDiscussion.node.notes.edges,
{ __typename: 'NoteEdge', node: createNote.note },
],
},
}, },
]; };
store.writeQuery({ const currentDiscussionIndex = data.design.discussions.edges.indexOf(currentDiscussion);
query: getDesignQuery,
data: { const payload = {
...data, ...data,
design: { design: {
...data.design, ...data.design,
notesCount: data.design.notesCount + 1, 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() { 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