mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Remove some Ember.Deferred
usage. It's deprecated.
This commit is contained in:
parent
39c7101c4b
commit
271374a8c6
2 changed files with 9 additions and 9 deletions
|
@ -313,14 +313,14 @@ Discourse.Utilities = {
|
|||
@method cropAvatar
|
||||
@param {String} url The url of the avatar
|
||||
@param {String} fileType The file type of the uploaded file
|
||||
@returns {Ember.Deferred} a promise that will eventually be the cropped avatar.
|
||||
@returns {Promise} a promise that will eventually be the cropped avatar.
|
||||
**/
|
||||
cropAvatar: function(url, fileType) {
|
||||
if (Discourse.SiteSettings.allow_animated_avatars && fileType === "image/gif") {
|
||||
// can't crop animated gifs... let the browser stretch the gif
|
||||
return Ember.RSVP.resolve(url);
|
||||
} else {
|
||||
return Ember.Deferred.promise(function(promise) {
|
||||
return new Ember.RSVP.Promise(function(resolve) {
|
||||
var image = document.createElement("img");
|
||||
// this event will be fired as soon as the image is loaded
|
||||
image.onload = function(e) {
|
||||
|
@ -345,7 +345,7 @@ Discourse.Utilities = {
|
|||
// draw the image into the canvas
|
||||
canvas.getContext("2d").drawImage(img, x, y, dimension, dimension, 0, 0, size, size);
|
||||
// retrieve the image from the canvas
|
||||
promise.resolve(canvas.toDataURL(fileType));
|
||||
resolve(canvas.toDataURL(fileType));
|
||||
};
|
||||
// launch the onload event
|
||||
image.src = url;
|
||||
|
|
|
@ -40,10 +40,10 @@ Discourse.Ajax = Em.Mixin.create({
|
|||
Ember.Logger.error("DEPRECATION: Discourse.ajax should use promises, received 'error' callback");
|
||||
}
|
||||
|
||||
var performAjax = function(promise) {
|
||||
var performAjax = function(resolve, reject) {
|
||||
var oldSuccess = args.success;
|
||||
args.success = function(xhr) {
|
||||
Ember.run(promise, promise.resolve, xhr);
|
||||
Ember.run(null, resolve, xhr);
|
||||
if (oldSuccess) oldSuccess(xhr);
|
||||
};
|
||||
|
||||
|
@ -63,7 +63,7 @@ Discourse.Ajax = Em.Mixin.create({
|
|||
xhr.jqTextStatus = textStatus;
|
||||
xhr.requestedUrl = url;
|
||||
|
||||
Ember.run(promise, promise.reject, xhr);
|
||||
Ember.run(null, reject, xhr);
|
||||
if (oldError) oldError(xhr);
|
||||
};
|
||||
|
||||
|
@ -82,15 +82,15 @@ Discourse.Ajax = Em.Mixin.create({
|
|||
// For cached pages we strip out CSRF tokens, need to round trip to server prior to sending the
|
||||
// request (bypass for GET, not needed)
|
||||
if(args.type && args.type.toUpperCase() !== 'GET' && !Discourse.Session.currentProp('csrfToken')){
|
||||
return Ember.Deferred.promise(function(promise){
|
||||
return new Ember.RSVP.Promise(function(resolve, reject){
|
||||
$.ajax(Discourse.getURL('/session/csrf'), {cache: false})
|
||||
.success(function(result){
|
||||
Discourse.Session.currentProp('csrfToken', result.csrf);
|
||||
performAjax(promise);
|
||||
performAjax(resolve, reject);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
return Ember.Deferred.promise(performAjax);
|
||||
return new Ember.RSVP.Promise(performAjax);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue