Merge pull request #5127 from Raven24/hpetru-2875-ignore-user-posts
Remove ignored peoples posts without refresh (II)
This commit is contained in:
commit
ae24495c7d
6 changed files with 54 additions and 20 deletions
|
|
@ -34,6 +34,7 @@
|
||||||
* Add rake task to send a mail to all users [#5111](https://github.com/diaspora/diaspora/pull/5111)
|
* Add rake task to send a mail to all users [#5111](https://github.com/diaspora/diaspora/pull/5111)
|
||||||
* Expose which services are configured in /statistics.json [#5121](https://github.com/diaspora/diaspora/pull/5121)
|
* Expose which services are configured in /statistics.json [#5121](https://github.com/diaspora/diaspora/pull/5121)
|
||||||
* In filtered notification views, replace "Mark all as read" with "Mark shown as read" [#5122](https://github.com/diaspora/diaspora/pull/5122)
|
* In filtered notification views, replace "Mark all as read" with "Mark shown as read" [#5122](https://github.com/diaspora/diaspora/pull/5122)
|
||||||
|
* When ignoring a user remove his posts from the stream instantly [#5127](https://github.com/diaspora/diaspora/pull/5127)
|
||||||
|
|
||||||
# 0.4.0.1
|
# 0.4.0.1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,16 @@ var app = {
|
||||||
pages: {},
|
pages: {},
|
||||||
forms: {},
|
forms: {},
|
||||||
|
|
||||||
|
// global event broker - use event names in the form of "object:action:data"
|
||||||
|
// [object]: the class of the acting object
|
||||||
|
// [action]: infinitive verb naming the performed action
|
||||||
|
// [data]: (optional) unique name or ID of the specific instance
|
||||||
|
// e.g. "person:ignore:123"
|
||||||
|
// if your event has to pass more than one datum (singular) - or in case you
|
||||||
|
// need structured data - specify them as arguments to the `#trigger` call
|
||||||
|
// e.g. `app.events.trigger('example:event', {more: 'data'})`
|
||||||
|
events: _.extend({}, Backbone.Events),
|
||||||
|
|
||||||
user: function(userAttrs) {
|
user: function(userAttrs) {
|
||||||
if(userAttrs) { return this._user = new app.models.User(userAttrs) }
|
if(userAttrs) { return this._user = new app.models.User(userAttrs) }
|
||||||
return this._user || false
|
return this._user || false
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,14 @@ app.models.Post = Backbone.Model.extend(_.extend({}, app.models.formatDateMixin,
|
||||||
return this.get("author")
|
return this.get("author")
|
||||||
},
|
},
|
||||||
|
|
||||||
|
blockAuthor: function() {
|
||||||
|
var personId = this.get("author").id;
|
||||||
|
var block = new app.models.Block();
|
||||||
|
|
||||||
|
return block.save({block : {person_id : personId}})
|
||||||
|
.done(function(){ app.events.trigger('person:block:'+personId); });
|
||||||
|
},
|
||||||
|
|
||||||
toggleFavorite : function(options){
|
toggleFavorite : function(options){
|
||||||
this.set({favorite : !this.get("favorite")})
|
this.set({favorite : !this.get("favorite")})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,9 @@ app.views.StreamPost = app.views.Post.extend({
|
||||||
tooltipSelector : ".timeago, .post_scope, .block_user, .delete",
|
tooltipSelector : ".timeago, .post_scope, .block_user, .delete",
|
||||||
|
|
||||||
initialize : function(){
|
initialize : function(){
|
||||||
|
var personId = this.model.get('author').id;
|
||||||
|
app.events.on('person:block:'+personId, this.remove, this);
|
||||||
|
|
||||||
this.model.on('remove', this.remove, this);
|
this.model.on('remove', this.remove, this);
|
||||||
//subviews
|
//subviews
|
||||||
this.commentStreamView = new app.views.CommentStream({model : this.model});
|
this.commentStreamView = new app.views.CommentStream({model : this.model});
|
||||||
|
|
@ -72,20 +75,13 @@ app.views.StreamPost = app.views.Post.extend({
|
||||||
if(evt) { evt.preventDefault(); }
|
if(evt) { evt.preventDefault(); }
|
||||||
if(!confirm(Diaspora.I18n.t('ignore_user'))) { return }
|
if(!confirm(Diaspora.I18n.t('ignore_user'))) { return }
|
||||||
|
|
||||||
var personId = this.model.get("author").id;
|
this.model.blockAuthor()
|
||||||
var block = new app.models.Block();
|
.fail(function() {
|
||||||
|
Diaspora.page.flashMessages.render({
|
||||||
block.save({block : {person_id : personId}}, {
|
success: false,
|
||||||
success : function(){
|
notice: Diaspora.I18n.t('ignore_failed')
|
||||||
if(!app.stream) { return }
|
});
|
||||||
|
});
|
||||||
_.each(app.stream.posts.models, function(model){
|
|
||||||
if(model.get("author").id == personId) {
|
|
||||||
app.stream.posts.remove(model);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
remove : function() {
|
remove : function() {
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ en:
|
||||||
created: "The report was successfully created"
|
created: "The report was successfully created"
|
||||||
exists: "The report already exists"
|
exists: "The report already exists"
|
||||||
ignore_user: "Ignore this user?"
|
ignore_user: "Ignore this user?"
|
||||||
|
ignore_failed: "Unable to ignore this user"
|
||||||
and: "and"
|
and: "and"
|
||||||
comma: ","
|
comma: ","
|
||||||
edit: "Edit"
|
edit: "Edit"
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,32 @@
|
||||||
describe("app.views.StreamPost", function(){
|
describe("app.views.StreamPost", function(){
|
||||||
beforeEach(function(){
|
beforeEach(function(){
|
||||||
this.PostViewClass = app.views.StreamPost
|
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.events.trigger('person:block:'+authorId);
|
||||||
|
expect(_PostViewClass.prototype.remove).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("#render", function(){
|
describe("#render", function(){
|
||||||
var o_embed_cache = {
|
var o_embed_cache = {
|
||||||
"data" : {
|
"data" : {
|
||||||
|
|
@ -32,12 +56,6 @@ describe("app.views.StreamPost", function(){
|
||||||
other : "<%= count %> Likes"
|
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(){
|
context("reshare", function(){
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue