Remove deprecated `error` callback to `Discourse.ajax`
This commit is contained in:
parent
ef6868d870
commit
c3874b6ec9
|
@ -186,25 +186,25 @@ Discourse.Topic = Discourse.Model.extend({
|
||||||
this.toggleProperty('bookmarked');
|
this.toggleProperty('bookmarked');
|
||||||
if (this.get("postStream.firstPostPresent")) { firstPost.toggleProperty("bookmarked"); }
|
if (this.get("postStream.firstPostPresent")) { firstPost.toggleProperty("bookmarked"); }
|
||||||
|
|
||||||
|
|
||||||
return Discourse.ajax('/t/' + this.get('id') + '/bookmark', {
|
return Discourse.ajax('/t/' + this.get('id') + '/bookmark', {
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
data: { bookmarked: self.get('bookmarked') },
|
data: { bookmarked: self.get('bookmarked') },
|
||||||
error: function(error){
|
}).catch(function(error) {
|
||||||
self.toggleProperty('bookmarked');
|
self.toggleProperty('bookmarked');
|
||||||
if (self.get("postStream.firstPostPresent")) { firstPost.toggleProperty('bookmarked'); }
|
if (self.get("postStream.firstPostPresent")) { firstPost.toggleProperty('bookmarked'); }
|
||||||
|
|
||||||
var showGenericError = true;
|
var showGenericError = true;
|
||||||
|
|
||||||
if (error && error.responseText) {
|
if (error && error.responseText) {
|
||||||
try {
|
try {
|
||||||
bootbox.alert($.parseJSON(error.responseText).errors);
|
bootbox.alert($.parseJSON(error.responseText).errors);
|
||||||
showGenericError = false;
|
showGenericError = false;
|
||||||
} catch(e){}
|
} catch(e){}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(showGenericError){
|
if(showGenericError){
|
||||||
bootbox.alert(I18n.t('generic_error'));
|
bootbox.alert(I18n.t('generic_error'));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,19 +7,18 @@ export default Discourse.View.extend(StringBuffer, {
|
||||||
classNameBindings: ['controller.checked',
|
classNameBindings: ['controller.checked',
|
||||||
':topic-list-item',
|
':topic-list-item',
|
||||||
'unboundClassNames',
|
'unboundClassNames',
|
||||||
'selected'
|
'selected'],
|
||||||
],
|
|
||||||
actions: {
|
actions: {
|
||||||
select: function(){
|
select: function(){
|
||||||
this.set('controller.selectedRow', this);
|
this.set('controller.selectedRow', this);
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleBookmark: function(){
|
toggleBookmark: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.get('topic').toggleBookmark().catch(function(){
|
this.get('topic').toggleBookmark().finally(function() {
|
||||||
self.rerender();
|
self.rerender();
|
||||||
});
|
});
|
||||||
self.rerender();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue