mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-05 16:58:59 +00:00
Filling out dashboard stories to handle hidden stories. Needs focus stories handling and marking read elsewhere.
This commit is contained in:
parent
587e7fb2a6
commit
11b3a1edff
6 changed files with 50 additions and 19 deletions
|
@ -285,7 +285,7 @@ class UserSubscription(models.Model):
|
||||||
stories_cached = rt.exists(ranked_stories_keys)
|
stories_cached = rt.exists(ranked_stories_keys)
|
||||||
unreads_cached = True if read_filter == "unread" else rt.exists(unread_ranked_stories_keys)
|
unreads_cached = True if read_filter == "unread" else rt.exists(unread_ranked_stories_keys)
|
||||||
if offset and stories_cached and unreads_cached:
|
if offset and stories_cached and unreads_cached:
|
||||||
story_hashes = range_func(ranked_stories_keys, offset, limit)
|
story_hashes = range_func(ranked_stories_keys, offset, offset+limit)
|
||||||
if read_filter == "unread":
|
if read_filter == "unread":
|
||||||
unread_story_hashes = story_hashes
|
unread_story_hashes = story_hashes
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1212,7 +1212,7 @@ def load_read_stories(request):
|
||||||
|
|
||||||
@json.json_view
|
@json.json_view
|
||||||
def load_river_stories__redis(request):
|
def load_river_stories__redis(request):
|
||||||
limit = request.REQUEST.get('limit', 12)
|
limit = int(request.REQUEST.get('limit', 12))
|
||||||
start = time.time()
|
start = time.time()
|
||||||
user = get_user(request)
|
user = get_user(request)
|
||||||
message = None
|
message = None
|
||||||
|
@ -1232,7 +1232,6 @@ def load_river_stories__redis(request):
|
||||||
code = 1
|
code = 1
|
||||||
user_search = None
|
user_search = None
|
||||||
offset = (page-1) * limit
|
offset = (page-1) * limit
|
||||||
limit = page * limit
|
|
||||||
story_date_order = "%sstory_date" % ('' if order == 'oldest' else '-')
|
story_date_order = "%sstory_date" % ('' if order == 'oldest' else '-')
|
||||||
|
|
||||||
if story_hashes:
|
if story_hashes:
|
||||||
|
|
|
@ -692,21 +692,27 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
fetch_dashboard_stories: function(feed_id, feeds, callback, error_callback) {
|
fetch_dashboard_stories: function(feed_id, feeds, page, callback, error_callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var pre_callback = function(data) {
|
var pre_callback = function(data) {
|
||||||
if (!NEWSBLUR.Globals.is_premium && NEWSBLUR.Globals.is_authenticated) {
|
if (!NEWSBLUR.Globals.is_premium && NEWSBLUR.Globals.is_authenticated) {
|
||||||
data.stories = data.stories.splice(0, 3);
|
data.stories = data.stories.splice(0, 3);
|
||||||
}
|
}
|
||||||
|
if (page > 1) {
|
||||||
|
self.dashboard_stories.add(data.stories, {silent: true});
|
||||||
|
self.dashboard_stories.trigger('add', {added: data.stories.length});
|
||||||
|
} else {
|
||||||
self.dashboard_stories.reset(data.stories, {added: data.stories.length});
|
self.dashboard_stories.reset(data.stories, {added: data.stories.length});
|
||||||
// console.log(['dashboard stories fetch', self.dashboard_stories.length, self.stories.length]);
|
}
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.make_request('/reader/river_stories', {
|
this.make_request('/reader/river_stories', {
|
||||||
feeds: feeds,
|
feeds: feeds,
|
||||||
limit: 4,
|
limit: 4,
|
||||||
|
page: page,
|
||||||
order: this.view_setting(feed_id, 'order'),
|
order: this.view_setting(feed_id, 'order'),
|
||||||
read_filter: this.view_setting(feed_id, 'read_filter'),
|
read_filter: this.view_setting(feed_id, 'read_filter'),
|
||||||
include_hidden: false
|
include_hidden: false
|
||||||
|
|
|
@ -17,18 +17,14 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
|
||||||
override_layout: 'split',
|
override_layout: 'split',
|
||||||
on_dashboard: true
|
on_dashboard: true
|
||||||
});
|
});
|
||||||
|
this.page = 1;
|
||||||
|
|
||||||
NEWSBLUR.assets.feeds.bind('reset', _.bind(this.load_stories, this));
|
NEWSBLUR.assets.feeds.bind('reset', _.bind(this.load_stories, this));
|
||||||
},
|
},
|
||||||
|
|
||||||
// ==========
|
feeds: function() {
|
||||||
// = Events =
|
|
||||||
// ==========
|
|
||||||
|
|
||||||
load_stories: function() {
|
|
||||||
// var feeds = NEWSBLUR.assets.folders.feed_ids_in_folder();
|
|
||||||
var visible_only = NEWSBLUR.assets.view_setting(this.active_feed, 'read_filter') == 'unread';
|
|
||||||
var feeds;
|
var feeds;
|
||||||
|
var visible_only = NEWSBLUR.assets.view_setting(this.active_feed, 'read_filter') == 'unread';
|
||||||
if (visible_only) {
|
if (visible_only) {
|
||||||
feeds = _.pluck(this.active_folder.feeds_with_unreads(), 'id');
|
feeds = _.pluck(this.active_folder.feeds_with_unreads(), 'id');
|
||||||
if (!feeds.length) {
|
if (!feeds.length) {
|
||||||
|
@ -38,13 +34,36 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
|
||||||
feeds = this.active_folder.feed_ids_in_folder();
|
feeds = this.active_folder.feed_ids_in_folder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return feeds;
|
||||||
|
},
|
||||||
|
|
||||||
|
// ==========
|
||||||
|
// = Events =
|
||||||
|
// ==========
|
||||||
|
|
||||||
|
load_stories: function() {
|
||||||
|
// var feeds = NEWSBLUR.assets.folders.feed_ids_in_folder();
|
||||||
|
var feeds = this.feeds();
|
||||||
|
|
||||||
|
this.page = 1;
|
||||||
this.story_titles.show_loading();
|
this.story_titles.show_loading();
|
||||||
NEWSBLUR.assets.fetch_dashboard_stories("river:", feeds,
|
NEWSBLUR.assets.fetch_dashboard_stories("river:", feeds, this.page,
|
||||||
_.bind(this.post_load_stories, this), NEWSBLUR.app.taskbar_info.show_stories_error);
|
_.bind(this.post_load_stories, this), NEWSBLUR.app.taskbar_info.show_stories_error);
|
||||||
},
|
},
|
||||||
|
|
||||||
post_load_stories: function() {
|
post_load_stories: function() {
|
||||||
|
this.fill_out();
|
||||||
|
},
|
||||||
|
|
||||||
|
fill_out: function() {
|
||||||
|
var visible = NEWSBLUR.assets.dashboard_stories.visible().length;
|
||||||
|
if (visible >= 5 || this.page > 10) return;
|
||||||
|
|
||||||
|
var feeds = this.feeds();
|
||||||
|
this.page += 1;
|
||||||
|
this.story_titles.show_loading();
|
||||||
|
NEWSBLUR.assets.fetch_dashboard_stories("river:", feeds, this.page,
|
||||||
|
_.bind(this.post_load_stories, this), NEWSBLUR.app.taskbar_info.show_stories_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
|
@ -462,7 +462,7 @@ NEWSBLUR.Views.StoryTitleView = Backbone.View.extend({
|
||||||
if (e.which == 1 && $('.NB-menu-manage-container:visible').length) return;
|
if (e.which == 1 && $('.NB-menu-manage-container:visible').length) return;
|
||||||
|
|
||||||
if (this.options.on_dashboard) {
|
if (this.options.on_dashboard) {
|
||||||
console.log(['clicked story', this.model]);
|
// console.log(['clicked story', this.model]);
|
||||||
NEWSBLUR.reader.open_river_stories(null, null, {story_id: this.model.id});
|
NEWSBLUR.reader.open_river_stories(null, null, {story_id: this.model.id});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ NEWSBLUR.Views.StoryTitlesView = Backbone.View.extend({
|
||||||
// console.log(['add story_titles', options]);
|
// console.log(['add story_titles', options]);
|
||||||
var collection = this.collection;
|
var collection = this.collection;
|
||||||
if (options.added) {
|
if (options.added) {
|
||||||
|
var on_dashboard = this.options.on_dashboard;
|
||||||
var story_layout = this.options.override_layout ||
|
var story_layout = this.options.override_layout ||
|
||||||
NEWSBLUR.assets.view_setting(NEWSBLUR.reader.active_feed, 'layout');
|
NEWSBLUR.assets.view_setting(NEWSBLUR.reader.active_feed, 'layout');
|
||||||
var stories = _.compact(_.map(this.collection.models.slice(-1 * options.added), function(story) {
|
var stories = _.compact(_.map(this.collection.models.slice(-1 * options.added), function(story) {
|
||||||
|
@ -65,7 +66,9 @@ NEWSBLUR.Views.StoryTitlesView = Backbone.View.extend({
|
||||||
return new NEWSBLUR.Views.StoryTitleView({
|
return new NEWSBLUR.Views.StoryTitleView({
|
||||||
model: story,
|
model: story,
|
||||||
collection: collection,
|
collection: collection,
|
||||||
is_grid: story_layout == 'grid'
|
is_grid: story_layout == 'grid',
|
||||||
|
override_layout: story_layout,
|
||||||
|
on_dashboard: on_dashboard
|
||||||
}).render();
|
}).render();
|
||||||
}));
|
}));
|
||||||
this.stories = this.stories.concat(stories);
|
this.stories = this.stories.concat(stories);
|
||||||
|
@ -73,6 +76,10 @@ NEWSBLUR.Views.StoryTitlesView = Backbone.View.extend({
|
||||||
return story.el;
|
return story.el;
|
||||||
});
|
});
|
||||||
this.$el.append($stories);
|
this.$el.append($stories);
|
||||||
|
if (this.options.on_dashboard) {
|
||||||
|
var $extras = this.$el.find('.NB-story-title-container').slice(5);
|
||||||
|
$extras.addClass('NB-hidden');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.end_loading();
|
this.end_loading();
|
||||||
this.fill_out();
|
this.fill_out();
|
||||||
|
|
Loading…
Add table
Reference in a new issue