From 63d3581e66acc21b79130c5f13bde88a74d136ac Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Mon, 12 Mar 2018 09:57:22 +0000 Subject: fixed note polling not sending updated last fetched at date added spec for polling --- app/assets/javascripts/notes/services/notes_service.js | 5 +++-- app/assets/javascripts/notes/stores/actions.js | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'app') diff --git a/app/assets/javascripts/notes/services/notes_service.js b/app/assets/javascripts/notes/services/notes_service.js index bb31be583c7..b4c19a9ec22 100644 --- a/app/assets/javascripts/notes/services/notes_service.js +++ b/app/assets/javascripts/notes/services/notes_service.js @@ -27,10 +27,11 @@ export default { return Vue.http[method](endpoint); }, poll(data = {}) { - const { endpoint, lastFetchedAt } = data; + const endpoint = data.notesData.notesPath; + const lastFetchedAt = data.lastFetchedAt; const options = { headers: { - 'X-Last-Fetched-At': `${lastFetchedAt}`, + 'X-Last-Fetched-At': lastFetchedAt ? `${lastFetchedAt}` : undefined, }, }; diff --git a/app/assets/javascripts/notes/stores/actions.js b/app/assets/javascripts/notes/stores/actions.js index 3eaae0bc683..fc7faf05c5f 100644 --- a/app/assets/javascripts/notes/stores/actions.js +++ b/app/assets/javascripts/notes/stores/actions.js @@ -203,12 +203,10 @@ const pollSuccessCallBack = (resp, commit, state, getters) => { }; export const poll = ({ commit, state, getters }) => { - const requestData = { endpoint: state.notesData.notesPath, lastFetchedAt: state.lastFetchedAt }; - eTagPoll = new Poll({ resource: service, method: 'poll', - data: requestData, + data: state, successCallback: resp => resp.json() .then(data => pollSuccessCallBack(data, commit, state, getters)), errorCallback: () => Flash('Something went wrong while fetching latest comments.'), @@ -217,7 +215,7 @@ export const poll = ({ commit, state, getters }) => { if (!Visibility.hidden()) { eTagPoll.makeRequest(); } else { - service.poll(requestData); + service.poll(state); } Visibility.change(() => { -- cgit v1.2.1