mirror of
https://github.com/discourse/discourse.git
synced 2025-04-26 22:24:46 +08:00
Remove deprecated Discourse.ajax
methods.
This commit is contained in:
parent
c3874b6ec9
commit
68c2eb9a5b
@ -34,22 +34,19 @@ Discourse.Ajax = Em.Mixin.create({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args.success) {
|
if (args.success) {
|
||||||
Ember.Logger.error("DEPRECATION: Discourse.ajax should use promises, received 'success' callback");
|
throw "Discourse.ajax should use promises, received 'success' callback";
|
||||||
}
|
}
|
||||||
if (args.error) {
|
if (args.error) {
|
||||||
Ember.Logger.error("DEPRECATION: Discourse.ajax should use promises, received 'error' callback");
|
throw "DEPRECATION: Discourse.ajax should use promises, received 'error' callback";
|
||||||
}
|
}
|
||||||
|
|
||||||
var performAjax = function(resolve, reject) {
|
var performAjax = function(resolve, reject) {
|
||||||
var oldSuccess = args.success;
|
|
||||||
args.success = function(xhr) {
|
args.success = function(xhr) {
|
||||||
Ember.run(null, resolve, xhr);
|
Ember.run(null, resolve, xhr);
|
||||||
if (oldSuccess) oldSuccess(xhr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var oldError = args.error;
|
|
||||||
args.error = function(xhr, textStatus) {
|
args.error = function(xhr, textStatus) {
|
||||||
|
|
||||||
// note: for bad CSRF we don't loop an extra request right away.
|
// note: for bad CSRF we don't loop an extra request right away.
|
||||||
// this allows us to eliminate the possibility of having a loop.
|
// this allows us to eliminate the possibility of having a loop.
|
||||||
if (xhr.status === 403 && xhr.responseText === "['BAD CSRF']") {
|
if (xhr.status === 403 && xhr.responseText === "['BAD CSRF']") {
|
||||||
@ -63,10 +60,7 @@ Discourse.Ajax = Em.Mixin.create({
|
|||||||
xhr.jqTextStatus = textStatus;
|
xhr.jqTextStatus = textStatus;
|
||||||
xhr.requestedUrl = url;
|
xhr.requestedUrl = url;
|
||||||
|
|
||||||
// TODO is this sequence correct? we are calling catch defined externally before
|
|
||||||
// the error that was defined inline, it should probably be in reverse
|
|
||||||
Ember.run(null, reject, xhr);
|
Ember.run(null, reject, xhr);
|
||||||
if (oldError) oldError(xhr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// We default to JSON on GET. If we don't, sometimes if the server doesn't return the proper header
|
// We default to JSON on GET. If we don't, sometimes if the server doesn't return the proper header
|
||||||
|
Loading…
x
Reference in New Issue
Block a user