From c3874b6ec970f14ddd7f39147c3d70f6094f7f19 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 5 Feb 2015 10:44:33 -0500 Subject: [PATCH] Remove deprecated `error` callback to `Discourse.ajax` --- .../javascripts/discourse/models/topic.js | 26 +++++++++---------- .../discourse/views/topic-list-item.js.es6 | 9 +++---- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/discourse/models/topic.js b/app/assets/javascripts/discourse/models/topic.js index 3103726655e..fd7ec8a7bb5 100644 --- a/app/assets/javascripts/discourse/models/topic.js +++ b/app/assets/javascripts/discourse/models/topic.js @@ -186,25 +186,25 @@ Discourse.Topic = Discourse.Model.extend({ this.toggleProperty('bookmarked'); if (this.get("postStream.firstPostPresent")) { firstPost.toggleProperty("bookmarked"); } + return Discourse.ajax('/t/' + this.get('id') + '/bookmark', { type: 'PUT', data: { bookmarked: self.get('bookmarked') }, - error: function(error){ - self.toggleProperty('bookmarked'); - if (self.get("postStream.firstPostPresent")) { firstPost.toggleProperty('bookmarked'); } + }).catch(function(error) { + self.toggleProperty('bookmarked'); + if (self.get("postStream.firstPostPresent")) { firstPost.toggleProperty('bookmarked'); } - var showGenericError = true; + var showGenericError = true; - if (error && error.responseText) { - try { - bootbox.alert($.parseJSON(error.responseText).errors); - showGenericError = false; - } catch(e){} - } + if (error && error.responseText) { + try { + bootbox.alert($.parseJSON(error.responseText).errors); + showGenericError = false; + } catch(e){} + } - if(showGenericError){ - bootbox.alert(I18n.t('generic_error')); - } + if(showGenericError){ + bootbox.alert(I18n.t('generic_error')); } }); }, diff --git a/app/assets/javascripts/discourse/views/topic-list-item.js.es6 b/app/assets/javascripts/discourse/views/topic-list-item.js.es6 index 00f4aa7cf21..f7f033817eb 100644 --- a/app/assets/javascripts/discourse/views/topic-list-item.js.es6 +++ b/app/assets/javascripts/discourse/views/topic-list-item.js.es6 @@ -7,19 +7,18 @@ export default Discourse.View.extend(StringBuffer, { classNameBindings: ['controller.checked', ':topic-list-item', 'unboundClassNames', - 'selected' - ], + 'selected'], + actions: { select: function(){ this.set('controller.selectedRow', this); }, - toggleBookmark: function(){ + toggleBookmark: function() { var self = this; - this.get('topic').toggleBookmark().catch(function(){ + this.get('topic').toggleBookmark().finally(function() { self.rerender(); }); - self.rerender(); } },