Refactor destroyModel function in base view

closes #7385
This commit is contained in:
Steffen van Bergerem 2017-03-23 01:02:33 +01:00 committed by Benjamin Neff
parent 3ce4bba383
commit 8a98cd4517
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
2 changed files with 10 additions and 8 deletions

View file

@ -9,6 +9,7 @@
* Don't hide posts when blocking someone from the profile [#7379](https://github.com/diaspora/diaspora/pull/7379) * Don't hide posts when blocking someone from the profile [#7379](https://github.com/diaspora/diaspora/pull/7379)
* Disable autocomplete for the conversation form recipient input [#7375](https://github.com/diaspora/diaspora/pull/7375) * Disable autocomplete for the conversation form recipient input [#7375](https://github.com/diaspora/diaspora/pull/7375)
* Fix sharing indicator on profile page for blocked users [#7382](https://github.com/diaspora/diaspora/pull/7382) * Fix sharing indicator on profile page for blocked users [#7382](https://github.com/diaspora/diaspora/pull/7382)
* Remove post only after a successful deletion on the server [#7385](https://github.com/diaspora/diaspora/pull/7385)
## Features ## Features
* Add links to liked and commented pages [#5502](https://github.com/diaspora/diaspora/pull/5502) * Add links to liked and commented pages [#5502](https://github.com/diaspora/diaspora/pull/5502)

View file

@ -132,19 +132,20 @@ app.views.Base = Backbone.View.extend({
destroyModel: function(evt) { destroyModel: function(evt) {
evt && evt.preventDefault(); evt && evt.preventDefault();
var self = this;
var url = this.model.urlRoot + "/" + this.model.id; var url = this.model.urlRoot + "/" + this.model.id;
if( confirm(_.result(this, "destroyConfirmMsg")) ) { if( confirm(_.result(this, "destroyConfirmMsg")) ) {
this.$el.addClass("deleting"); this.$el.addClass("deleting");
this.model.destroy({ url: url }) this.model.destroy({
.done(function() { url: url,
self.remove(); success: function() {
}) this.remove();
.fail(function() { }.bind(this),
self.$el.removeClass("deleting"); error: function() {
this.$el.removeClass("deleting");
app.flashMessages.error(Diaspora.I18n.t("failed_to_remove")); app.flashMessages.error(Diaspora.I18n.t("failed_to_remove"));
}); }.bind(this)
});
} }
}, },