mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-31 21:41:33 +00:00
Marking stories as read inline when using mark newer/older stories read and order matches so stories are visible.
This commit is contained in:
parent
4f1fdbb8bf
commit
c9ba9d9b22
3 changed files with 68 additions and 67 deletions
|
@ -142,36 +142,9 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
mark_story_as_read: function(story, feed, callback) {
|
|
||||||
var self = this;
|
|
||||||
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]);
|
|
||||||
|
|
||||||
this.make_request('/reader/mark_story_as_read', {
|
|
||||||
story_id: this.queued_read_stories[feed.id],
|
|
||||||
feed_id: feed.id
|
|
||||||
}, null, null, {
|
|
||||||
'ajax_group': 'queue_clear',
|
|
||||||
'beforeSend': function() {
|
|
||||||
self.queued_read_stories = {};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$.isFunction(callback) && callback(read);
|
|
||||||
},
|
|
||||||
|
|
||||||
mark_story_hash_as_read: function(story, callback) {
|
mark_story_hash_as_read: function(story, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var read = story.get('read_status');
|
var previously_read = story.get('read_status');
|
||||||
|
|
||||||
if (!story.get('read_status')) {
|
if (!story.get('read_status')) {
|
||||||
story.set('read_status', 1);
|
story.set('read_status', 1);
|
||||||
|
@ -192,7 +165,7 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$.isFunction(callback) && callback(read);
|
$.isFunction(callback) && callback(previously_read);
|
||||||
},
|
},
|
||||||
|
|
||||||
mark_social_story_as_read: function(story, social_feed, callback) {
|
mark_social_story_as_read: function(story, social_feed, callback) {
|
||||||
|
@ -323,11 +296,6 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
||||||
direction: direction
|
direction: direction
|
||||||
}, callback);
|
}, callback);
|
||||||
|
|
||||||
_.each(feed_ids, function(feed_id) {
|
|
||||||
var feed = self.get_feed(feed_id);
|
|
||||||
if (!feed) return;
|
|
||||||
feed.set({'ps': 0, 'nt': 0, 'ng': 0});
|
|
||||||
});
|
|
||||||
if (mark_active) {
|
if (mark_active) {
|
||||||
this.stories.each(function(story) {
|
this.stories.each(function(story) {
|
||||||
if ((!direction || direction == "older") &&
|
if ((!direction || direction == "older") &&
|
||||||
|
@ -339,7 +307,26 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
||||||
parseInt(story.get('story_timestamp'), 10) < cutoff_timestamp) {
|
parseInt(story.get('story_timestamp'), 10) < cutoff_timestamp) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
story.set('read_status', true);
|
if (!story.get('read_status')) {
|
||||||
|
story.set('read_status', true);
|
||||||
|
var score = story.score();
|
||||||
|
var feed = self.get_feed(story.get('story_feed_id'));
|
||||||
|
if (!feed) return;
|
||||||
|
if (score > 0) {
|
||||||
|
feed.set('ps', feed.get('ps') - 1);
|
||||||
|
} else if (score == 0) {
|
||||||
|
feed.set('nt', feed.get('nt') - 1);
|
||||||
|
} else if (score < 0) {
|
||||||
|
feed.set('ng', feed.get('ng') - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
_.each(feed_ids, function(feed_id) {
|
||||||
|
var feed = self.get_feed(feed_id);
|
||||||
|
if (!feed) return;
|
||||||
|
|
||||||
|
feed.set({'ps': 0, 'nt': 0, 'ng': 0});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1108,7 +1095,13 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
||||||
|
|
||||||
get_story: function(story_id) {
|
get_story: function(story_id) {
|
||||||
var self = this;
|
var self = this;
|
||||||
return this.stories.get(story_id);
|
var story = this.stories.get(story_id);
|
||||||
|
if (!story) {
|
||||||
|
story = this.stories.detect(function (story) {
|
||||||
|
return story.get('story_hash') == story_id;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return story;
|
||||||
},
|
},
|
||||||
|
|
||||||
get_user: function(user_id) {
|
get_user: function(user_id) {
|
||||||
|
|
|
@ -2319,18 +2319,9 @@
|
||||||
|
|
||||||
mark_feed_as_read: function(feed_id, days_back, direction) {
|
mark_feed_as_read: function(feed_id, days_back, direction) {
|
||||||
feed_id = feed_id || this.active_feed;
|
feed_id = feed_id || this.active_feed;
|
||||||
var cutoff_timestamp = NEWSBLUR.utils.days_back_to_timestamp(days_back);
|
|
||||||
if (!days_back && this.model.stories.length &&
|
|
||||||
this.model.stories.first().get('story_feed_id') == feed_id &&
|
|
||||||
NEWSBLUR.assets.view_setting(feed_id, 'order') == 'newest') {
|
|
||||||
cutoff_timestamp = this.model.stories.first().get('story_timestamp');
|
|
||||||
}
|
|
||||||
|
|
||||||
this.model.mark_feed_as_read([feed_id], cutoff_timestamp, direction,
|
|
||||||
feed_id == this.active_feed, _.bind(function() {
|
|
||||||
this.feed_unread_count(feed_id);
|
|
||||||
}, this));
|
|
||||||
|
|
||||||
|
this.mark_feeds_as_read([feed_id], days_back, direction);
|
||||||
|
|
||||||
if (!direction && NEWSBLUR.assets.preference('markread_nextfeed') == 'nextfeed' &&
|
if (!direction && NEWSBLUR.assets.preference('markread_nextfeed') == 'nextfeed' &&
|
||||||
NEWSBLUR.reader.active_feed == feed_id) {
|
NEWSBLUR.reader.active_feed == feed_id) {
|
||||||
this.show_next_feed(1);
|
this.show_next_feed(1);
|
||||||
|
@ -2340,26 +2331,37 @@
|
||||||
mark_folder_as_read: function(folder, days_back, direction) {
|
mark_folder_as_read: function(folder, days_back, direction) {
|
||||||
var folder = folder || this.active_folder;
|
var folder = folder || this.active_folder;
|
||||||
var feeds = folder.feed_ids_in_folder();
|
var feeds = folder.feed_ids_in_folder();
|
||||||
var cutoff_timestamp = NEWSBLUR.utils.days_back_to_timestamp(days_back);
|
|
||||||
if (!days_back && this.model.stories.length &&
|
|
||||||
_.contains(feeds, this.model.stories.first().get('story_feed_id')) &&
|
|
||||||
folder.view_setting('order') == 'newest') {
|
|
||||||
cutoff_timestamp = this.model.stories.first().get('story_timestamp');
|
|
||||||
}
|
|
||||||
|
|
||||||
this.model.mark_feed_as_read(feeds, cutoff_timestamp, direction,
|
this.mark_feeds_as_read(feeds, days_back, direction);
|
||||||
folder == this.active_folder, _.bind(function() {
|
|
||||||
if (!this.socket || !this.socket || !this.socket.connected) {
|
|
||||||
this.force_feeds_refresh(null, false, feeds);
|
|
||||||
}
|
|
||||||
}, this));
|
|
||||||
|
|
||||||
if (!direction && NEWSBLUR.assets.preference('markread_nextfeed') == 'nextfeed' &&
|
if (!direction && NEWSBLUR.assets.preference('markread_nextfeed') == 'nextfeed' &&
|
||||||
NEWSBLUR.reader.active_folder == folder) {
|
NEWSBLUR.reader.active_folder == folder) {
|
||||||
this.show_next_feed(1);
|
this.show_next_feed(1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
mark_feeds_as_read: function(feeds, days_back, direction) {
|
||||||
|
var order = NEWSBLUR.assets.view_setting(this.active_feed, 'order');
|
||||||
|
var stories_not_visible = true;
|
||||||
|
var cutoff_timestamp = parseInt(NEWSBLUR.utils.days_back_to_timestamp(days_back) || 0, 10);
|
||||||
|
if (!days_back && this.model.stories.length &&
|
||||||
|
_.contains(feeds, this.model.stories.first().get('story_feed_id')) &&
|
||||||
|
order == 'newest') {
|
||||||
|
cutoff_timestamp = this.model.stories.first().get('story_timestamp');
|
||||||
|
}
|
||||||
|
var mark_active = false;
|
||||||
|
if ((order == 'newest' && direction == 'newer') || (order == 'oldest' && direction == 'older')) {
|
||||||
|
mark_active = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.model.mark_feed_as_read(feeds, cutoff_timestamp, direction,
|
||||||
|
mark_active, _.bind(function() {
|
||||||
|
if (!this.socket || !this.socket || !this.socket.connected) {
|
||||||
|
this.force_feeds_refresh(null, false, feeds);
|
||||||
|
}
|
||||||
|
}, this));
|
||||||
|
},
|
||||||
|
|
||||||
open_story_trainer: function(story_id, feed_id, options) {
|
open_story_trainer: function(story_id, feed_id, options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
story_id = story_id || this.active_story && this.active_story.id;
|
story_id = story_id || this.active_story && this.active_story.id;
|
||||||
|
@ -6674,11 +6676,14 @@
|
||||||
if (!NEWSBLUR.reader.active_story) return;
|
if (!NEWSBLUR.reader.active_story) return;
|
||||||
var story = NEWSBLUR.assets.get_story(NEWSBLUR.reader.active_story);
|
var story = NEWSBLUR.assets.get_story(NEWSBLUR.reader.active_story);
|
||||||
var timestamp = story.get('story_timestamp');
|
var timestamp = story.get('story_timestamp');
|
||||||
|
var direction = 'newer';
|
||||||
|
var order = NEWSBLUR.assets.view_setting(self.active_feed, 'order');
|
||||||
|
if (order == 'oldest') direction = 'older';
|
||||||
|
|
||||||
if (self.flags.river_view && !self.flags.social_view) {
|
if (self.flags.river_view && !self.flags.social_view) {
|
||||||
self.mark_folder_as_read(self.active_folder, timestamp, 'newer');
|
self.mark_folder_as_read(self.active_folder, timestamp, direction);
|
||||||
} else {
|
} else {
|
||||||
self.mark_feed_as_read(self.active_feed, timestamp, 'newer');
|
self.mark_feed_as_read(self.active_feed, timestamp, direction);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$document.bind('keydown', 'shift+b', function(e) {
|
$document.bind('keydown', 'shift+b', function(e) {
|
||||||
|
@ -6686,11 +6691,14 @@
|
||||||
if (!NEWSBLUR.reader.active_story) return;
|
if (!NEWSBLUR.reader.active_story) return;
|
||||||
var story = NEWSBLUR.assets.get_story(NEWSBLUR.reader.active_story);
|
var story = NEWSBLUR.assets.get_story(NEWSBLUR.reader.active_story);
|
||||||
var timestamp = story.get('story_timestamp');
|
var timestamp = story.get('story_timestamp');
|
||||||
|
var direction = 'older';
|
||||||
|
var order = NEWSBLUR.assets.view_setting(self.active_feed, 'order');
|
||||||
|
if (order == 'oldest') direction = 'newer';
|
||||||
|
|
||||||
if (self.flags.river_view && !self.flags.social_view) {
|
if (self.flags.river_view && !self.flags.social_view) {
|
||||||
self.mark_folder_as_read(self.active_folder, timestamp, 'older');
|
self.mark_folder_as_read(self.active_folder, timestamp, order);
|
||||||
} else {
|
} else {
|
||||||
self.mark_feed_as_read(self.active_feed, timestamp, 'older');
|
self.mark_feed_as_read(self.active_feed, timestamp, order);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$document.bind('keydown', 'm', function(e) {
|
$document.bind('keydown', 'm', function(e) {
|
||||||
|
|
|
@ -289,7 +289,7 @@ _.extend(NEWSBLUR.ReaderKeyboard.prototype, {
|
||||||
]),
|
]),
|
||||||
$.make('div', { className: 'NB-keyboard-group' }, [
|
$.make('div', { className: 'NB-keyboard-group' }, [
|
||||||
$.make('div', { className: 'NB-keyboard-shortcut' }, [
|
$.make('div', { className: 'NB-keyboard-shortcut' }, [
|
||||||
$.make('div', { className: 'NB-keyboard-shortcut-explanation' }, 'Mark older stories read'),
|
$.make('div', { className: 'NB-keyboard-shortcut-explanation' }, 'Mark below stories read'),
|
||||||
$.make('div', { className: 'NB-keyboard-shortcut-key' }, [
|
$.make('div', { className: 'NB-keyboard-shortcut-key' }, [
|
||||||
'shift',
|
'shift',
|
||||||
$.make('span', '+'),
|
$.make('span', '+'),
|
||||||
|
@ -297,7 +297,7 @@ _.extend(NEWSBLUR.ReaderKeyboard.prototype, {
|
||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
$.make('div', { className: 'NB-keyboard-shortcut' }, [
|
$.make('div', { className: 'NB-keyboard-shortcut' }, [
|
||||||
$.make('div', { className: 'NB-keyboard-shortcut-explanation' }, 'Mark newer stories read'),
|
$.make('div', { className: 'NB-keyboard-shortcut-explanation' }, 'Mark above stories read'),
|
||||||
$.make('div', { className: 'NB-keyboard-shortcut-key' }, [
|
$.make('div', { className: 'NB-keyboard-shortcut-key' }, [
|
||||||
'shift',
|
'shift',
|
||||||
$.make('span', '+'),
|
$.make('span', '+'),
|
||||||
|
|
Loading…
Add table
Reference in a new issue