Fix TaskList init on update & poll

Fixed duplicate TaskList requests being made
This commit is contained in:
Phil Hughes 2018-11-09 11:04:13 +00:00
parent cfedc31b7a
commit 5796221bc4
No known key found for this signature in database
GPG key ID: 32245528C52E0F9F
3 changed files with 10 additions and 11 deletions

View file

@ -6,7 +6,6 @@ import Autosize from 'autosize';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import Flash from '../../flash'; import Flash from '../../flash';
import Autosave from '../../autosave'; import Autosave from '../../autosave';
import TaskList from '../../task_list';
import { import {
capitalizeFirstCharacter, capitalizeFirstCharacter,
convertToCamelCase, convertToCamelCase,
@ -146,7 +145,6 @@ export default {
}); });
this.initAutoSave(); this.initAutoSave();
this.initTaskList();
}, },
methods: { methods: {
...mapActions([ ...mapActions([
@ -298,13 +296,6 @@ Please check your network connection and try again.`;
]); ]);
} }
}, },
initTaskList() {
return new TaskList({
dataType: 'note',
fieldName: 'note',
selector: '.notes',
});
},
resizeTextarea() { resizeTextarea() {
this.$nextTick(() => { this.$nextTick(() => {
Autosize.update(this.$refs.textarea); Autosize.update(this.$refs.textarea);

View file

@ -60,12 +60,13 @@ export const deleteNote = ({ commit, dispatch }, note) =>
dispatch('updateMergeRequestWidget'); dispatch('updateMergeRequestWidget');
}); });
export const updateNote = ({ commit }, { endpoint, note }) => export const updateNote = ({ commit, dispatch }, { endpoint, note }) =>
service service
.updateNote(endpoint, note) .updateNote(endpoint, note)
.then(res => res.json()) .then(res => res.json())
.then(res => { .then(res => {
commit(types.UPDATE_NOTE, res); commit(types.UPDATE_NOTE, res);
Vue.nextTick(() => dispatch('startTaskList'));
}); });
export const replyToDiscussion = ({ commit }, { endpoint, data }) => export const replyToDiscussion = ({ commit }, { endpoint, data }) =>
@ -262,6 +263,8 @@ const pollSuccessCallBack = (resp, commit, state, getters, dispatch) => {
commit(types.ADD_NEW_NOTE, note); commit(types.ADD_NEW_NOTE, note);
} }
}); });
Vue.nextTick(() => dispatch('startTaskList'));
} }
commit(types.SET_LAST_FETCHED_AT, resp.last_fetched_at); commit(types.SET_LAST_FETCHED_AT, resp.last_fetched_at);
@ -375,7 +378,7 @@ export const startTaskList = ({ dispatch }) =>
dataType: 'note', dataType: 'note',
fieldName: 'note', fieldName: 'note',
selector: '.notes .is-editable', selector: '.notes .is-editable',
onSuccess: () => Vue.$nextTick(() => dispatch('startTaskList')), onSuccess: () => Vue.nextTick(() => dispatch('startTaskList')),
}); });
// prevent babel-plugin-rewire from generating an invalid default during karma tests // prevent babel-plugin-rewire from generating an invalid default during karma tests

View file

@ -0,0 +1,5 @@
---
title: Improve initial discussion rendering performance
merge_request: 22607
author:
type: changed