mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Correctly updating counts on stories read in social sites but also subscribed to by the user.
This commit is contained in:
parent
a086cd83d4
commit
05fce0124a
3 changed files with 27 additions and 22 deletions
|
@ -106,22 +106,21 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
|||
|
||||
},
|
||||
|
||||
mark_story_as_read: function(story_id, feed_id, callback) {
|
||||
mark_story_as_read: function(story, feed, callback) {
|
||||
var self = this;
|
||||
var story = this.get_story(story_id);
|
||||
var read = story.get('read_status');
|
||||
|
||||
if (!story.get('read_status')) {
|
||||
story.set('read_status', 1);
|
||||
|
||||
if (NEWSBLUR.Globals.is_authenticated) {
|
||||
if (!(feed_id in this.queued_read_stories)) { this.queued_read_stories[feed_id] = []; }
|
||||
this.queued_read_stories[feed_id].push(story_id);
|
||||
// NEWSBLUR.log(['Marking Read', this.queued_read_stories, story_id]);
|
||||
if (!(feed.id in this.queued_read_stories)) { this.queued_read_stories[feed.id] = []; }
|
||||
this.queued_read_stories[feed.id].push(story.id);
|
||||
// NEWSBLUR.log(['Marking Read', this.queued_read_stories, story.id]);
|
||||
|
||||
this.make_request('/reader/mark_story_as_read', {
|
||||
story_id: this.queued_read_stories[feed_id],
|
||||
feed_id: feed_id
|
||||
story_id: this.queued_read_stories[feed.id],
|
||||
feed_id: feed.id
|
||||
}, null, null, {
|
||||
'ajax_group': $.browser.msie ? 'rapid' : 'queue_clear',
|
||||
'beforeSend': function() {
|
||||
|
@ -135,11 +134,10 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
|||
$.isFunction(callback) && callback(read);
|
||||
},
|
||||
|
||||
mark_social_story_as_read: function(story_id, social_feed_id, callback) {
|
||||
mark_social_story_as_read: function(story, social_feed, callback) {
|
||||
var self = this;
|
||||
var story = this.get_story(story_id);
|
||||
var feed_id = story.get('story_feed_id');
|
||||
var social_user_id = this.social_feeds.get(social_feed_id).get('user_id');
|
||||
var social_user_id = social_feed.get('user_id');
|
||||
var read = story.get('read_status');
|
||||
|
||||
if (!story.get('read_status')) {
|
||||
|
@ -152,8 +150,8 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
|||
if (!(feed_id in this.queued_read_stories[social_user_id])) {
|
||||
this.queued_read_stories[social_user_id][feed_id] = [];
|
||||
}
|
||||
this.queued_read_stories[social_user_id][feed_id].push(story_id);
|
||||
// NEWSBLUR.log(['Marking Read', this.queued_read_stories, story_id]);
|
||||
this.queued_read_stories[social_user_id][feed_id].push(story.id);
|
||||
// NEWSBLUR.log(['Marking Read', this.queued_read_stories, story.id]);
|
||||
|
||||
this.make_request('/reader/mark_social_stories_as_read', {
|
||||
users_feeds_stories: $.toJSON(this.queued_read_stories)
|
||||
|
|
|
@ -6,7 +6,7 @@ NEWSBLUR.Models.SocialSubscription = Backbone.Model.extend({
|
|||
}
|
||||
|
||||
_.bindAll(this, 'on_change', 'on_remove');
|
||||
this.bind('change', this.on_change);
|
||||
// this.bind('change', this.on_change);
|
||||
this.bind('remove', this.on_remove);
|
||||
this.views = [];
|
||||
},
|
||||
|
|
|
@ -92,11 +92,11 @@ NEWSBLUR.Collections.Stories = Backbone.Collection.extend({
|
|||
this.read_story_delay = _.delay(_.bind(function() {
|
||||
if (delay || this.last_read_story_id == story.id || delay == 0) {
|
||||
var mark_read_fn = NEWSBLUR.assets.mark_story_as_read;
|
||||
var feed = NEWSBLUR.assets.get_feed(story.get('story_feed_id'));
|
||||
var feed = NEWSBLUR.assets.get_feed(NEWSBLUR.reader.active_feed);
|
||||
if (feed.is_social()) {
|
||||
mark_read_fn = NEWSBLUR.assets.mark_social_story_as_read;
|
||||
}
|
||||
mark_read_fn.call(NEWSBLUR.assets, story.id, story.get('story_feed_id'), _.bind(function(read) {
|
||||
mark_read_fn.call(NEWSBLUR.assets, story, feed, _.bind(function(read) {
|
||||
this.update_read_count(story, {previously_read: read});
|
||||
}, this));
|
||||
story.set('read_status', 1);
|
||||
|
@ -119,17 +119,24 @@ NEWSBLUR.Collections.Stories = Backbone.Collection.extend({
|
|||
|
||||
var story_unread_counter = NEWSBLUR.app.story_unread_counter;
|
||||
var unread_view = NEWSBLUR.reader.get_unread_view_name();
|
||||
var feed = NEWSBLUR.assets.get_feed(story.get('story_feed_id'));
|
||||
var active_feed = NEWSBLUR.assets.get_feed(NEWSBLUR.reader.active_feed);
|
||||
var story_feed = NEWSBLUR.assets.get_feed(story.get('story_feed_id'));
|
||||
|
||||
if (story.score() > 0) {
|
||||
var count = Math.max(feed.get('ps') + (options.unread?1:-1), 0);
|
||||
feed.set('ps', count, {instant: true});
|
||||
var active_count = Math.max(active_feed.get('ps') + (options.unread?1:-1), 0);
|
||||
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});
|
||||
} else if (story.score() == 0) {
|
||||
var count = Math.max(feed.get('nt') + (options.unread?1:-1), 0);
|
||||
feed.set('nt', count, {instant: true});
|
||||
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});
|
||||
} else if (story.score() < 0) {
|
||||
var count = Math.max(feed.get('ng') + (options.unread?1:-1), 0);
|
||||
feed.set('ng', count, {instant: true});
|
||||
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});
|
||||
}
|
||||
|
||||
if (story_unread_counter) {
|
||||
|
|
Loading…
Add table
Reference in a new issue