Converted a bunch of ajax calls to use promises

This commit is contained in:
Robin Ward
2013-04-03 16:06:55 -04:00
parent 33f349a1e6
commit 5ec41d454c
11 changed files with 117 additions and 158 deletions

View File

@ -166,19 +166,17 @@ Discourse = Ember.Application.createWithMixins({
**/
logout: function() {
Discourse.KeyValueStore.abandonLocal();
return Discourse.ajax(Discourse.getURL("/session/") + this.get('currentUser.username'), {
type: 'DELETE',
success: function(result) {
// To keep lots of our variables unbound, we can handle a redirect on logging out.
window.location.reload();
}
Discourse.ajax(Discourse.getURL("/session/") + this.get('currentUser.username'), {
type: 'DELETE'
}).then(function() {
// Reloading will refresh unbound properties
window.location.reload();
});
},
authenticationComplete: function(options) {
// TODO, how to dispatch this to the view without the container?
var loginView;
loginView = Discourse.__container__.lookup('controller:modal').get('currentView');
var loginView = Discourse.__container__.lookup('controller:modal').get('currentView');
return loginView.authenticationComplete(options);
},