Unverified Commit 8a98cd45 authored by Steffen van Bergerem's avatar Steffen van Bergerem Committed by Benjamin Neff

Refactor destroyModel function in base view

closes #7385
parent 3ce4bba3
......@@ -9,6 +9,7 @@
* 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)
* 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
* Add links to liked and commented pages [#5502](https://github.com/diaspora/diaspora/pull/5502)
......
......@@ -132,18 +132,19 @@ app.views.Base = Backbone.View.extend({
destroyModel: function(evt) {
evt && evt.preventDefault();
var self = this;
var url = this.model.urlRoot + "/" + this.model.id;
if( confirm(_.result(this, "destroyConfirmMsg")) ) {
this.$el.addClass("deleting");
this.model.destroy({ url: url })
.done(function() {
self.remove();
})
.fail(function() {
self.$el.removeClass("deleting");
this.model.destroy({
url: url,
success: function() {
this.remove();
}.bind(this),
error: function() {
this.$el.removeClass("deleting");
app.flashMessages.error(Diaspora.I18n.t("failed_to_remove"));
}.bind(this)
});
}
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment