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