mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Marking friend socialsubs as read when reading a story from another feed or socialsub where the friend has shared the story.
This commit is contained in:
parent
4fb6e67617
commit
4fc9693b36
2 changed files with 24 additions and 1 deletions
|
@ -137,6 +137,9 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
|||
var self = this;
|
||||
var feed_id = story.get('story_feed_id');
|
||||
var social_user_id = social_feed.get('user_id');
|
||||
if (!social_user_id) {
|
||||
social_user_id = story.get('shared_by_friends')[0];
|
||||
}
|
||||
var read = story.get('read_status');
|
||||
|
||||
if (!story.get('read_status')) {
|
||||
|
@ -768,6 +771,12 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
|||
}
|
||||
},
|
||||
|
||||
get_friend_feeds: function(story) {
|
||||
return _.map(story.get('shared_by_friends'), _.bind(function(user_id) {
|
||||
return this.social_feeds.get('social:'+user_id);
|
||||
}, this));
|
||||
},
|
||||
|
||||
get_feeds: function() {
|
||||
var self = this;
|
||||
|
||||
|
|
|
@ -100,7 +100,8 @@ NEWSBLUR.Collections.Stories = Backbone.Collection.extend({
|
|||
if (!feed) {
|
||||
feed = NEWSBLUR.assets.get_feed(story.get('story_feed_id'));
|
||||
}
|
||||
if (feed && feed.is_social()) {
|
||||
if ((feed && feed.is_social()) ||
|
||||
NEWSBLUR.reader.active_feed == 'river:blurblogs') {
|
||||
mark_read_fn = NEWSBLUR.assets.mark_social_story_as_read;
|
||||
}
|
||||
mark_read_fn.call(NEWSBLUR.assets, story, feed, _.bind(function(read) {
|
||||
|
@ -128,6 +129,7 @@ NEWSBLUR.Collections.Stories = Backbone.Collection.extend({
|
|||
var unread_view = NEWSBLUR.reader.get_unread_view_name();
|
||||
var active_feed = NEWSBLUR.assets.get_feed(NEWSBLUR.reader.active_feed);
|
||||
var story_feed = NEWSBLUR.assets.get_feed(story.get('story_feed_id'));
|
||||
var friend_feeds = NEWSBLUR.assets.get_friend_feeds(story);
|
||||
|
||||
if (!active_feed) {
|
||||
// River of News does not have an active feed.
|
||||
|
@ -138,16 +140,28 @@ NEWSBLUR.Collections.Stories = Backbone.Collection.extend({
|
|||
var story_count = Math.max(story_feed.get('ps') + (options.unread?1:-1), 0);
|
||||
active_feed.set('ps', active_count, {instant: true});
|
||||
story_feed.set('ps', story_count, {instant: true});
|
||||
_.each(friend_feeds, function(socialsub) {
|
||||
var socialsub_count = Math.max(socialsub.get('ps') + (options.unread?1:-1), 0);
|
||||
socialsub.set('ps', socialsub_count, {instant: true});
|
||||
});
|
||||
} else if (story.score() == 0) {
|
||||
var active_count = Math.max(active_feed.get('nt') + (options.unread?1:-1), 0);
|
||||
var story_count = Math.max(story_feed.get('nt') + (options.unread?1:-1), 0);
|
||||
active_feed.set('nt', active_count, {instant: true});
|
||||
story_feed.set('nt', story_count, {instant: true});
|
||||
_.each(friend_feeds, function(socialsub) {
|
||||
var socialsub_count = Math.max(socialsub.get('nt') + (options.unread?1:-1), 0);
|
||||
socialsub.set('nt', socialsub_count, {instant: true});
|
||||
});
|
||||
} else if (story.score() < 0) {
|
||||
var active_count = Math.max(active_feed.get('ng') + (options.unread?1:-1), 0);
|
||||
var story_count = Math.max(story_feed.get('ng') + (options.unread?1:-1), 0);
|
||||
active_feed.set('ng', active_count, {instant: true});
|
||||
story_feed.set('ng', story_count, {instant: true});
|
||||
_.each(friend_feeds, function(socialsub) {
|
||||
var socialsub_count = Math.max(socialsub.get('ng') + (options.unread?1:-1), 0);
|
||||
socialsub.set('ng', socialsub_count, {instant: true});
|
||||
});
|
||||
}
|
||||
|
||||
if (story_unread_counter) {
|
||||
|
|
Loading…
Add table
Reference in a new issue