From 2497c29ef0d1e178c8b3aa96e8304ee6765bae4e Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 14 Sep 2018 16:51:25 +0100 Subject: Use returned discussion from API We now use the returned discussion instead of re-fetching all of the discussions and filtering out the ones we don't need. This speeds up the process of creating a diff discussions by saving us another API request before we can render the discussion --- app/assets/javascripts/notes/stores/mutations.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/assets/javascripts/notes/stores/mutations.js') diff --git a/app/assets/javascripts/notes/stores/mutations.js b/app/assets/javascripts/notes/stores/mutations.js index f1242a0d8be..73e55705f39 100644 --- a/app/assets/javascripts/notes/stores/mutations.js +++ b/app/assets/javascripts/notes/stores/mutations.js @@ -4,7 +4,8 @@ import * as constants from '../constants'; import { isInMRPage } from '../../lib/utils/common_utils'; export default { - [types.ADD_NEW_NOTE](state, note) { + [types.ADD_NEW_NOTE](state, data) { + const note = data.discussion ? data.discussion.notes[0] : data; const { discussion_id, type } = note; const [exists] = state.discussions.filter(n => n.id === note.discussion_id); const isDiscussion = type === constants.DISCUSSION_NOTE || type === constants.DIFF_NOTE; -- cgit v1.2.1