mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Merge branch 'comments'
* comments: Showing comment-less replies even if no comments. Adding new comment-less replies. Just needs testing and it's ready to ship.
This commit is contained in:
commit
8652bfb1fd
6 changed files with 69 additions and 5 deletions
|
@ -1840,6 +1840,7 @@ class MSharedStory(mongo.Document):
|
|||
profile_user_ids = set()
|
||||
for story in stories:
|
||||
story['friend_comments'] = []
|
||||
story['friend_shares'] = []
|
||||
story['public_comments'] = []
|
||||
story['reply_count'] = 0
|
||||
if check_all or story['comment_count']:
|
||||
|
@ -1895,6 +1896,21 @@ class MSharedStory(mongo.Document):
|
|||
story['share_user_ids'] = story['friend_user_ids'] + story['public_user_ids']
|
||||
if story.get('source_user_id'):
|
||||
profile_user_ids.add(story['source_user_id'])
|
||||
shared_stories = []
|
||||
if story['shared_by_friends']:
|
||||
params = {
|
||||
'story_hash': story['story_hash'],
|
||||
'user_id__in': story['shared_by_friends'],
|
||||
}
|
||||
shared_stories = cls.objects.filter(**params)
|
||||
for shared_story in shared_stories:
|
||||
comments = shared_story.comments_with_author()
|
||||
story['reply_count'] += len(comments['replies'])
|
||||
story['friend_shares'].append(comments)
|
||||
if comments.get('source_user_id'):
|
||||
profile_user_ids.add(comments['source_user_id'])
|
||||
if comments.get('liking_users'):
|
||||
profile_user_ids = profile_user_ids.union(comments['liking_users'])
|
||||
|
||||
profiles = MSocialProfile.objects.filter(user_id__in=list(profile_user_ids))
|
||||
profiles = [profile.canonical(compact=True) for profile in profiles]
|
||||
|
|
|
@ -3213,6 +3213,9 @@ body {
|
|||
left: 6px;
|
||||
z-index: 1;
|
||||
}
|
||||
.NB-story-comment .NB-story-comment-friend-share .NB-story-comment-author-avatar.NB-user-avatar.NB-story-comment-reshare {
|
||||
top: 10px;
|
||||
}
|
||||
.NB-story-comment .NB-story-comment-author-avatar.NB-user-avatar img {
|
||||
border-radius: 6px;
|
||||
margin: 2px 0 0 1px;
|
||||
|
@ -3223,10 +3226,21 @@ body {
|
|||
height: 24px;
|
||||
width: 24px;
|
||||
}
|
||||
.NB-story-comment .NB-story-comment-friend-share .NB-story-comment-author-avatar.NB-user-avatar img {
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
margin-left: 6px;
|
||||
}
|
||||
.NB-story-comment .NB-story-comment-friend-share .NB-story-comment-author-avatar.NB-user-avatar.NB-story-comment-reshare img {
|
||||
margin-left: 0px;
|
||||
}
|
||||
.NB-story-comment .NB-story-comment-author-container {
|
||||
overflow: hidden;
|
||||
margin: 6px 0 0;
|
||||
}
|
||||
.NB-story-comment .NB-story-comment-friend-share .NB-story-comment-author-container {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.NB-story-comment .NB-story-comment-reshares {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
@ -3283,7 +3297,8 @@ body {
|
|||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
.NB-story-comment .NB-story-comment-likes-users .NB-story-share-profile .NB-user-avatar img {
|
||||
.NB-story-comment .NB-story-comment-likes-users .NB-story-share-profile .NB-user-avatar img,
|
||||
.NB-story-comment .NB-story-comment-friend-share .NB-story-comment-likes-users .NB-story-share-profile .NB-user-avatar img {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}
|
||||
|
@ -3536,6 +3551,11 @@ body {
|
|||
height: 22px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.NB-story-comment-friend-share .NB-story-share-profile .NB-user-avatar img.NB-user-avatar-image {
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
}
|
||||
|
||||
.NB-story-share-profile .NB-user-avatar img.NB-user-avatar-private {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
|
|
|
@ -14,6 +14,7 @@ NEWSBLUR.Models.Story = Backbone.Model.extend({
|
|||
|
||||
populate_comments: function(story, collection) {
|
||||
this.friend_comments = new NEWSBLUR.Collections.Comments(this.get('friend_comments'));
|
||||
this.friend_shares = new NEWSBLUR.Collections.Comments(this.get('friend_shares'));
|
||||
this.public_comments = new NEWSBLUR.Collections.Comments(this.get('public_comments'));
|
||||
},
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ NEWSBLUR.Views.StoryComment = Backbone.View.extend({
|
|||
var has_likes = _.any(this.model.get('liking_users'));
|
||||
var liked = _.contains(this.model.get('liking_users'), NEWSBLUR.Globals.user_id);
|
||||
|
||||
var $comment = $.make('div', [
|
||||
var $comment = $.make('div', { className: (this.options.friend_share ? "NB-story-comment-friend-share" : "") }, [
|
||||
$.make('div', { className: 'NB-story-comment-author-avatar NB-user-avatar ' + reshare_class }, [
|
||||
$.make('img', { src: this.user.get('photo_url') })
|
||||
]),
|
||||
|
|
|
@ -17,8 +17,10 @@ NEWSBLUR.Views.StoryCommentsView = Backbone.View.extend({
|
|||
}));
|
||||
this.render_teaser();
|
||||
this.render_comments_friends();
|
||||
this.render_shares_friends();
|
||||
this.render_comments_public();
|
||||
this.$el.toggleClass('NB-hidden', !this.model.get('comment_count'));
|
||||
this.$el.toggleClass('NB-hidden', (!this.model.get('comment_count') &&
|
||||
!this.model.get('share_count_friends')));
|
||||
}
|
||||
|
||||
return this;
|
||||
|
@ -41,7 +43,7 @@ NEWSBLUR.Views.StoryCommentsView = Backbone.View.extend({
|
|||
var $thumb = NEWSBLUR.Views.ProfileThumb.create(user_id).render().el;
|
||||
$comments_public.append($thumb);
|
||||
});
|
||||
if (!this.model.friend_comments.length && !this.model.public_comments.length) {
|
||||
if (!this.model.friend_comments.length && !this.model.public_comments.length && !this.model.friend_shares.length) {
|
||||
this.$el.hide();
|
||||
}
|
||||
|
||||
|
@ -86,6 +88,30 @@ NEWSBLUR.Views.StoryCommentsView = Backbone.View.extend({
|
|||
this.$el.append($comment);
|
||||
}, this));
|
||||
},
|
||||
|
||||
render_shares_friends: function() {
|
||||
var shares_without_comments = this.model.get('shared_by_friends');
|
||||
if (shares_without_comments.length <= 0) return;
|
||||
|
||||
var $header = $.make('div', {
|
||||
className: 'NB-story-comments-public-header-wrapper'
|
||||
}, $.make('div', {
|
||||
className: 'NB-story-comments-public-header NB-module-header'
|
||||
}, [
|
||||
Inflector.pluralize(' share', shares_without_comments.length, true)
|
||||
]));
|
||||
|
||||
this.$el.append($header);
|
||||
|
||||
this.model.friend_shares.each(_.bind(function(comment) {
|
||||
var $comment = new NEWSBLUR.Views.StoryComment({
|
||||
model: comment,
|
||||
story: this.model,
|
||||
friend_share: true
|
||||
}).render().el;
|
||||
this.$el.append($comment);
|
||||
}, this));
|
||||
},
|
||||
|
||||
render_comments_public: function() {
|
||||
if (!this.model.get('comment_count_public') || !this.model.get('comment_count')) return;
|
||||
|
|
|
@ -280,7 +280,8 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
|
|||
var $original_comments = this.$('.NB-feed-story-comments-container,.NB-feed-story-comments');
|
||||
var $original_shares = this.$('.NB-feed-story-shares-container,.NB-feed-story-shares');
|
||||
if (this.model.get("comment_count") || this.model.get("share_count")) {
|
||||
this.comments_view = new NEWSBLUR.Views.StoryCommentsView({model: this.model}).render();
|
||||
var comments_view = new NEWSBLUR.Views.StoryCommentsView({model: this.model});
|
||||
this.comments_view = comments_view.render();
|
||||
var $comments = this.comments_view.el;
|
||||
$original_comments.replaceWith($comments);
|
||||
var $shares = $('.NB-story-comments-shares-teaser-wrapper', $comments);
|
||||
|
|
Loading…
Add table
Reference in a new issue