diff options
-rw-r--r-- | app/assets/javascripts/notes/components/issue_notes.vue | 11 | ||||
-rw-r--r-- | app/assets/javascripts/notes/stores/issue_notes_store.js | 8 |
2 files changed, 10 insertions, 9 deletions
diff --git a/app/assets/javascripts/notes/components/issue_notes.vue b/app/assets/javascripts/notes/components/issue_notes.vue index a0c951df822..95ab4a5e254 100644 --- a/app/assets/javascripts/notes/components/issue_notes.vue +++ b/app/assets/javascripts/notes/components/issue_notes.vue @@ -61,17 +61,14 @@ export default { }); }, initPolling() { - const { notesPath, lastFetchedAt } = this.$el.parentNode.dataset; - const options = { - endpoint: `${notesPath}?full_data=1`, - lastFetchedAt, - }; + const { lastFetchedAt } = $('.js-notes-wrapper')[0].dataset; + this.$store.commit('setLastFetchedAt', lastFetchedAt); // FIXME: @fatihacet Implement real polling mechanism setInterval(() => { - this.$store.dispatch('poll', options) + this.$store.dispatch('poll') .then((res) => { - options.lastFetchedAt = res.last_fetched_at; + this.$store.commit('setLastFetchedAt', res.lastFetchedAt); }) .catch(() => { new Flash('Something went wrong while fetching latest comments.'); // eslint-disable-line diff --git a/app/assets/javascripts/notes/stores/issue_notes_store.js b/app/assets/javascripts/notes/stores/issue_notes_store.js index a5811515fc4..ef5bb8dce3d 100644 --- a/app/assets/javascripts/notes/stores/issue_notes_store.js +++ b/app/assets/javascripts/notes/stores/issue_notes_store.js @@ -7,6 +7,7 @@ const findNoteObjectById = (notes, id) => notes.filter(n => n.id === id)[0]; const state = { notes: [], targetNoteHash: null, + lastFetchedAt: null, }; const getters = { @@ -104,6 +105,9 @@ const mutations = { }); } }, + setLastFetchedAt(storeState, fetchedAt) { + storeState.lastFetchedAt = fetchedAt; + }, }; const actions = { @@ -156,10 +160,10 @@ const actions = { }); }, poll(context, data) { - const { endpoint, lastFetchedAt } = data; + const { notesPath } = $('.js-notes-wrapper')[0].dataset; return service - .poll(endpoint, lastFetchedAt) + .poll(`${notesPath}?full_data=1`, context.state.lastFetchedAt) .then(res => res.json()) .then((res) => { if (res.notes.length) { |