Commit 3ce4bba3 authored by Steffen van Bergerem's avatar Steffen van Bergerem Committed by Benjamin Neff

Only remove post from stream after successful response

Pass destroyModel from post control view to post view
and don't listen to the remove event in the post view
anymore. The `remove` function will be called from the
base view.

Fixes #5445
parent aa55a7a0
......@@ -76,6 +76,10 @@ app.views.PostControls = app.views.Base.extend({
$.post(Routes.postParticipation(this.model.get("id")), {_method: "delete"}, function() {
this.model.set({participation: false});
}.bind(this));
},
destroyModel: function() {
this.post.destroyModel();
}
});
// @license-end
......@@ -33,7 +33,6 @@ app.views.StreamPost = app.views.Post.extend({
var personId = this.model.get("author").id;
app.events.on("person:block:" + personId, this.remove, this);
}
this.model.on("remove", this.remove, this);
//subviews
this.commentStreamView = new app.views.CommentStream({model : this.model});
this.oEmbedView = new app.views.OEmbed({model : this.model});
......
......@@ -4,7 +4,8 @@
margin: 0px;
}
&.deleting {
> .media { opacity: 0.3; }
opacity: .3;
.control-icons { display: none !important; }
}
}
......
......@@ -74,12 +74,15 @@ describe("app.views.PostControls", function() {
});
it("calls destroyModel when removing a post", function() {
spyOn(app.views.PostControls.prototype, "destroyModel");
spyOn(app.views.PostControls.prototype, "destroyModel").and.callThrough();
spyOn(app.views.Post.prototype, "destroyModel");
app.currentUser = new app.models.User(this.model.attributes.author);
this.view = new app.views.PostControls({model: this.model});
this.postView = new app.views.Post({model: this.model});
this.view = new app.views.PostControls({model: this.model, post: this.postView});
this.view.render();
this.view.$(".remove_post.delete").click();
expect(app.views.PostControls.prototype.destroyModel).toHaveBeenCalled();
expect(app.views.Post.prototype.destroyModel).toHaveBeenCalled();
});
it("calls hidePost when hiding a post", function() {
......
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