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

View File

@ -60,12 +60,13 @@ export const deleteNote = ({ commit, dispatch }, note) =>
dispatch('updateMergeRequestWidget');
});
export const updateNote = ({ commit }, { endpoint, note }) =>
export const updateNote = ({ commit, dispatch }, { endpoint, note }) =>
service
.updateNote(endpoint, note)
.then(res => res.json())
.then(res => {
commit(types.UPDATE_NOTE, res);
Vue.nextTick(() => dispatch('startTaskList'));
});
export const replyToDiscussion = ({ commit }, { endpoint, data }) =>
@ -262,6 +263,8 @@ const pollSuccessCallBack = (resp, commit, state, getters, dispatch) => {
commit(types.ADD_NEW_NOTE, note);
}
});
Vue.nextTick(() => dispatch('startTaskList'));
}
commit(types.SET_LAST_FETCHED_AT, resp.last_fetched_at);
@ -375,7 +378,7 @@ export const startTaskList = ({ dispatch }) =>
dataType: 'note',
fieldName: 'note',
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

View File

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