diff options
author | Fatih Acet <acetfatih@gmail.com> | 2018-07-09 08:39:32 +0000 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2018-07-09 08:39:32 +0000 |
commit | dc71b4004bd9773d03d5a4eeaba2db883e5a2251 (patch) | |
tree | 50d0fb2a7da911b31f1ce4e5f7d39176ee986b35 | |
parent | a7bc7940a0f2ebc57994661a982ecb44894d1ee1 (diff) | |
parent | e5b7fa6baf2963a96d188965b3dd3537033a0e82 (diff) | |
download | gitlab-ce-dc71b4004bd9773d03d5a4eeaba2db883e5a2251.tar.gz |
Merge branch '48906-adding-a-diff-line-note-freezes-the-browser' into 'master'
Resolve "Adding a diff line note freezes the browser"
Closes #48906
See merge request gitlab-org/gitlab-ce!20476
-rw-r--r-- | app/assets/javascripts/diffs/components/diff_line_note_form.vue | 6 | ||||
-rw-r--r-- | app/assets/javascripts/notes/stores/actions.js | 9 | ||||
-rw-r--r-- | app/assets/javascripts/notes/stores/mutations.js | 1 |
3 files changed, 12 insertions, 4 deletions
diff --git a/app/assets/javascripts/diffs/components/diff_line_note_form.vue b/app/assets/javascripts/diffs/components/diff_line_note_form.vue index 6943b462e86..f48cf80153f 100644 --- a/app/assets/javascripts/diffs/components/diff_line_note_form.vue +++ b/app/assets/javascripts/diffs/components/diff_line_note_form.vue @@ -59,7 +59,7 @@ export default { } }, methods: { - ...mapActions(['cancelCommentForm', 'saveNote', 'fetchDiscussions']), + ...mapActions(['cancelCommentForm', 'saveNote', 'refetchDiscussionById']), handleCancelCommentForm() { this.autosave.reset(); this.cancelCommentForm({ @@ -78,10 +78,10 @@ export default { }); this.saveNote(postData) - .then(() => { + .then(result => { const endpoint = this.getNotesDataByProp('discussionsPath'); - this.fetchDiscussions(endpoint) + this.refetchDiscussionById({ path: endpoint, discussionId: result.discussion_id }) .then(() => { this.handleCancelCommentForm(); }) diff --git a/app/assets/javascripts/notes/stores/actions.js b/app/assets/javascripts/notes/stores/actions.js index 671fa4d7d22..b2bf86eea56 100644 --- a/app/assets/javascripts/notes/stores/actions.js +++ b/app/assets/javascripts/notes/stores/actions.js @@ -41,6 +41,15 @@ export const fetchDiscussions = ({ commit }, path) => commit(types.SET_INITIAL_DISCUSSIONS, discussions); }); +export const refetchDiscussionById = ({ commit }, { path, discussionId }) => + service + .fetchDiscussions(path) + .then(res => res.json()) + .then(discussions => { + const selectedDiscussion = discussions.find(discussion => discussion.id === discussionId); + if (selectedDiscussion) commit(types.UPDATE_DISCUSSION, selectedDiscussion); + }); + export const deleteNote = ({ commit }, note) => service.deleteNote(note.path).then(() => { commit(types.DELETE_NOTE, note); diff --git a/app/assets/javascripts/notes/stores/mutations.js b/app/assets/javascripts/notes/stores/mutations.js index e5e40ce07fa..a1849269010 100644 --- a/app/assets/javascripts/notes/stores/mutations.js +++ b/app/assets/javascripts/notes/stores/mutations.js @@ -114,7 +114,6 @@ export default { Object.assign(state, { discussions }); }, - [types.SET_LAST_FETCHED_AT](state, fetchedAt) { Object.assign(state, { lastFetchedAt: fetchedAt }); }, |