diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /app/assets/javascripts/notes/stores/actions.js | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'app/assets/javascripts/notes/stores/actions.js')
-rw-r--r-- | app/assets/javascripts/notes/stores/actions.js | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/app/assets/javascripts/notes/stores/actions.js b/app/assets/javascripts/notes/stores/actions.js index f6069b509e8..9c63a7e3cd4 100644 --- a/app/assets/javascripts/notes/stores/actions.js +++ b/app/assets/javascripts/notes/stores/actions.js @@ -87,6 +87,7 @@ export const fetchDiscussions = ({ commit, dispatch }, { path, filter, persistFi return axios.get(path, config).then(({ data }) => { commit(types.SET_INITIAL_DISCUSSIONS, data); + commit(types.SET_FETCHING_DISCUSSIONS, false); dispatch('updateResolvableDiscussionsCounts'); }); @@ -136,6 +137,23 @@ export const updateNote = ({ commit, dispatch }, { endpoint, note }) => export const updateOrCreateNotes = ({ commit, state, getters, dispatch }, notes) => { const { notesById } = getters; + const debouncedFetchDiscussions = isFetching => { + if (!isFetching) { + commit(types.SET_FETCHING_DISCUSSIONS, true); + dispatch('fetchDiscussions', { path: state.notesData.discussionsPath }); + } else { + if (isFetching !== true) { + clearTimeout(state.currentlyFetchingDiscussions); + } + + commit( + types.SET_FETCHING_DISCUSSIONS, + setTimeout(() => { + dispatch('fetchDiscussions', { path: state.notesData.discussionsPath }); + }, constants.DISCUSSION_FETCH_TIMEOUT), + ); + } + }; notes.forEach(note => { if (notesById[note.id]) { @@ -146,7 +164,7 @@ export const updateOrCreateNotes = ({ commit, state, getters, dispatch }, notes) if (discussion) { commit(types.ADD_NEW_REPLY_TO_DISCUSSION, note); } else if (note.type === constants.DIFF_NOTE) { - dispatch('fetchDiscussions', { path: state.notesData.discussionsPath }); + debouncedFetchDiscussions(state.currentlyFetchingDiscussions); } else { commit(types.ADD_NEW_NOTE, note); } @@ -457,7 +475,7 @@ export const poll = ({ commit, state, getters, dispatch }) => { }); if (!Visibility.hidden()) { - eTagPoll.makeRequest(); + eTagPoll.makeDelayedRequest(2500); } else { dispatch('fetchData'); } |