Commit 1c8553f2 authored by Phil Hughes's avatar Phil Hughes

Converted notes.js to axios

parent c09a89c7
...@@ -16,6 +16,7 @@ import Autosize from 'autosize'; ...@@ -16,6 +16,7 @@ import Autosize from 'autosize';
import 'vendor/jquery.caret'; // required by jquery.atwho import 'vendor/jquery.caret'; // required by jquery.atwho
import 'vendor/jquery.atwho'; import 'vendor/jquery.atwho';
import AjaxCache from '~/lib/utils/ajax_cache'; import AjaxCache from '~/lib/utils/ajax_cache';
import axios from './lib/utils/axios_utils';
import { getLocationHash } from './lib/utils/url_utility'; import { getLocationHash } from './lib/utils/url_utility';
import Flash from './flash'; import Flash from './flash';
import CommentTypeToggle from './comment_type_toggle'; import CommentTypeToggle from './comment_type_toggle';
...@@ -252,26 +253,20 @@ export default class Notes { ...@@ -252,26 +253,20 @@ export default class Notes {
return; return;
} }
this.refreshing = true; this.refreshing = true;
return $.ajax({ axios.get(this.notes_url, {
url: this.notes_url, headers: {
headers: { 'X-Last-Fetched-At': this.last_fetched_at }, 'X-Last-Fetched-At': this.last_fetched_at,
dataType: 'json', },
success: (function(_this) { }).then(({ data }) => {
return function(data) { const notes = data.notes;
var notes; this.last_fetched_at = data.last_fetched_at;
notes = data.notes; this.setPollingInterval(data.notes.length);
_this.last_fetched_at = data.last_fetched_at; $.each(notes, (i, note) => this.renderNote(note));
_this.setPollingInterval(data.notes.length);
return $.each(notes, function(i, note) { this.refreshing = false;
_this.renderNote(note); }).catch(() => {
}); this.refreshing = false;
}; });
})(this)
}).always((function(_this) {
return function() {
return _this.refreshing = false;
};
})(this));
} }
/** /**
......
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