Remove posts for ignored person

This commit is contained in:
Hincu Petru 2014-06-25 00:57:47 +00:00
parent b246c7b5ef
commit 653612b74d
4 changed files with 30 additions and 13 deletions

View file

@ -3,6 +3,7 @@
## Refactor
## Bug fixes
* Fix which allow to remove ignored users posts without page refresh [#2875](https://github.com/diaspora/diaspora/issues/2875)
## Features

View file

@ -19,6 +19,7 @@ var app = {
views: {},
pages: {},
forms: {},
vent: _.extend({}, Backbone.Events),
user: function(userAttrs) {
if(userAttrs) { return this._user = new app.models.User(userAttrs) }

View file

@ -27,6 +27,9 @@ app.views.StreamPost = app.views.Post.extend({
tooltipSelector : ".timeago, .post_scope, .block_user, .delete",
initialize : function(){
var personId = this.model.get('author').id;
app.vent.on('remove:author:posts:'+personId, this.remove, this);
this.model.on('remove', this.remove, this);
//subviews
this.commentStreamView = new app.views.CommentStream({model : this.model});
@ -77,13 +80,7 @@ app.views.StreamPost = app.views.Post.extend({
block.save({block : {person_id : personId}}, {
success : function(){
if(!app.stream) { return }
_.each(app.stream.posts.models, function(model){
if(model.get("author").id == personId) {
app.stream.posts.remove(model);
}
})
app.vent.trigger('remove:author:posts:'+personId);
}
})
},

View file

@ -1,8 +1,32 @@
describe("app.views.StreamPost", function(){
beforeEach(function(){
this.PostViewClass = app.views.StreamPost
var posts = $.parseJSON(spec.readFixture("stream_json"));
this.collection = new app.collections.Posts(posts);
this.statusMessage = this.collection.models[0];
this.reshare = this.collection.models[1];
})
describe("events", function(){
var _PostViewClass = undefined;
var author_id = undefined;
beforeEach(function(){
_PostViewClass = this.PostViewClass;
authorId = this.statusMessage.get('author').id;
});
describe("remove posts for blocked person", function(){
it("setup remove:author:posts:#{id} to #remove", function(){
spyOn(_PostViewClass.prototype, 'remove');
view = new _PostViewClass({model : this.statusMessage});
app.vent.trigger('remove:author:posts:'+authorId);
expect(_PostViewClass.prototype.remove).toHaveBeenCalled();
});
});
});
describe("#render", function(){
var o_embed_cache = {
"data" : {
@ -32,12 +56,6 @@ describe("app.views.StreamPost", function(){
other : "<%= count %> Likes"
}
}})
var posts = $.parseJSON(spec.readFixture("stream_json"));
this.collection = new app.collections.Posts(posts);
this.statusMessage = this.collection.models[0];
this.reshare = this.collection.models[1];
})
context("reshare", function(){