Commit aa2fd250 authored by Phil Hughes's avatar Phil Hughes

Fixes applied state with batch suggestions

parent 9d193f5d
...@@ -559,7 +559,7 @@ export const updateResolvableDiscussionsCounts = ({ commit }) => ...@@ -559,7 +559,7 @@ export const updateResolvableDiscussionsCounts = ({ commit }) =>
export const submitSuggestion = ( export const submitSuggestion = (
{ commit, dispatch }, { commit, dispatch },
{ discussionId, noteId, suggestionId, flashContainer }, { discussionId, suggestionId, flashContainer },
) => { ) => {
const dispatchResolveDiscussion = () => const dispatchResolveDiscussion = () =>
dispatch('resolveDiscussion', { discussionId }).catch(() => {}); dispatch('resolveDiscussion', { discussionId }).catch(() => {});
...@@ -589,11 +589,6 @@ export const submitSuggestion = ( ...@@ -589,11 +589,6 @@ export const submitSuggestion = (
export const submitSuggestionBatch = ({ commit, dispatch, state }, { flashContainer }) => { export const submitSuggestionBatch = ({ commit, dispatch, state }, { flashContainer }) => {
const suggestionIds = state.batchSuggestionsInfo.map(({ suggestionId }) => suggestionId); const suggestionIds = state.batchSuggestionsInfo.map(({ suggestionId }) => suggestionId);
const applyAllSuggestions = () =>
state.batchSuggestionsInfo.map((suggestionInfo) =>
commit(types.APPLY_SUGGESTION, suggestionInfo),
);
const resolveAllDiscussions = () => const resolveAllDiscussions = () =>
state.batchSuggestionsInfo.map((suggestionInfo) => { state.batchSuggestionsInfo.map((suggestionInfo) => {
const { discussionId } = suggestionInfo; const { discussionId } = suggestionInfo;
...@@ -605,7 +600,6 @@ export const submitSuggestionBatch = ({ commit, dispatch, state }, { flashContai ...@@ -605,7 +600,6 @@ export const submitSuggestionBatch = ({ commit, dispatch, state }, { flashContai
dispatch('stopPolling'); dispatch('stopPolling');
return Api.applySuggestionBatch(suggestionIds) return Api.applySuggestionBatch(suggestionIds)
.then(() => Promise.all(applyAllSuggestions()))
.then(() => Promise.all(resolveAllDiscussions())) .then(() => Promise.all(resolveAllDiscussions()))
.then(() => commit(types.CLEAR_SUGGESTION_BATCH)) .then(() => commit(types.CLEAR_SUGGESTION_BATCH))
.catch((err) => { .catch((err) => {
......
...@@ -1000,8 +1000,6 @@ describe('Actions Notes Store', () => { ...@@ -1000,8 +1000,6 @@ describe('Actions Notes Store', () => {
expect(commit.mock.calls).toEqual([ expect(commit.mock.calls).toEqual([
[mutationTypes.SET_APPLYING_BATCH_STATE, true], [mutationTypes.SET_APPLYING_BATCH_STATE, true],
[mutationTypes.SET_RESOLVING_DISCUSSION, true], [mutationTypes.SET_RESOLVING_DISCUSSION, true],
[mutationTypes.APPLY_SUGGESTION, batchSuggestionsInfo[0]],
[mutationTypes.APPLY_SUGGESTION, batchSuggestionsInfo[1]],
[mutationTypes.CLEAR_SUGGESTION_BATCH], [mutationTypes.CLEAR_SUGGESTION_BATCH],
[mutationTypes.SET_APPLYING_BATCH_STATE, false], [mutationTypes.SET_APPLYING_BATCH_STATE, false],
[mutationTypes.SET_RESOLVING_DISCUSSION, false], [mutationTypes.SET_RESOLVING_DISCUSSION, false],
...@@ -1065,8 +1063,6 @@ describe('Actions Notes Store', () => { ...@@ -1065,8 +1063,6 @@ describe('Actions Notes Store', () => {
expect(commit.mock.calls).toEqual([ expect(commit.mock.calls).toEqual([
[mutationTypes.SET_APPLYING_BATCH_STATE, true], [mutationTypes.SET_APPLYING_BATCH_STATE, true],
[mutationTypes.SET_RESOLVING_DISCUSSION, true], [mutationTypes.SET_RESOLVING_DISCUSSION, true],
[mutationTypes.APPLY_SUGGESTION, batchSuggestionsInfo[0]],
[mutationTypes.APPLY_SUGGESTION, batchSuggestionsInfo[1]],
[mutationTypes.CLEAR_SUGGESTION_BATCH], [mutationTypes.CLEAR_SUGGESTION_BATCH],
[mutationTypes.SET_APPLYING_BATCH_STATE, false], [mutationTypes.SET_APPLYING_BATCH_STATE, false],
[mutationTypes.SET_RESOLVING_DISCUSSION, false], [mutationTypes.SET_RESOLVING_DISCUSSION, false],
......
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