2016-11-29 17:26:17 -08:00
|
|
|
NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
|
|
|
|
|
|
|
|
el: ".NB-module-river",
|
|
|
|
|
|
|
|
events: {
|
|
|
|
"click .NB-module-search-add-url" : "add_url"
|
|
|
|
},
|
|
|
|
|
|
|
|
initialize: function() {
|
2016-12-01 12:47:01 -08:00
|
|
|
this.active_feed = 'river:';
|
|
|
|
this.active_folder = NEWSBLUR.assets.folders;
|
2016-11-30 20:06:24 -08:00
|
|
|
this.$stories = this.$(".NB-module-item .NB-story-titles");
|
2016-11-29 17:26:17 -08:00
|
|
|
this.story_titles = new NEWSBLUR.Views.StoryTitlesView({
|
2016-11-30 18:53:32 -08:00
|
|
|
el: this.$stories,
|
2016-11-29 17:26:17 -08:00
|
|
|
collection: NEWSBLUR.assets.dashboard_stories,
|
2016-11-30 17:55:25 -08:00
|
|
|
$story_titles: this.$stories,
|
2016-11-30 18:53:32 -08:00
|
|
|
override_layout: 'split',
|
|
|
|
on_dashboard: true
|
2016-11-29 17:26:17 -08:00
|
|
|
});
|
2016-12-01 14:27:18 -08:00
|
|
|
this.page = 1;
|
2016-11-29 17:26:17 -08:00
|
|
|
|
|
|
|
NEWSBLUR.assets.feeds.bind('reset', _.bind(this.load_stories, this));
|
|
|
|
},
|
|
|
|
|
2016-12-01 14:27:18 -08:00
|
|
|
feeds: function() {
|
2016-12-01 12:47:01 -08:00
|
|
|
var feeds;
|
2016-12-01 14:27:18 -08:00
|
|
|
var visible_only = NEWSBLUR.assets.view_setting(this.active_feed, 'read_filter') == 'unread';
|
2016-12-01 12:47:01 -08:00
|
|
|
if (visible_only) {
|
|
|
|
feeds = _.pluck(this.active_folder.feeds_with_unreads(), 'id');
|
|
|
|
if (!feeds.length) {
|
|
|
|
feeds = this.active_folder.feed_ids_in_folder();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
feeds = this.active_folder.feed_ids_in_folder();
|
|
|
|
}
|
|
|
|
|
2016-12-01 14:27:18 -08:00
|
|
|
return feeds;
|
|
|
|
},
|
|
|
|
|
|
|
|
// ==========
|
|
|
|
// = Events =
|
|
|
|
// ==========
|
|
|
|
|
|
|
|
load_stories: function() {
|
|
|
|
// var feeds = NEWSBLUR.assets.folders.feed_ids_in_folder();
|
|
|
|
var feeds = this.feeds();
|
|
|
|
|
|
|
|
this.page = 1;
|
2016-11-29 17:26:17 -08:00
|
|
|
this.story_titles.show_loading();
|
2016-12-01 14:27:18 -08:00
|
|
|
NEWSBLUR.assets.fetch_dashboard_stories("river:", feeds, this.page,
|
2016-11-29 17:26:17 -08:00
|
|
|
_.bind(this.post_load_stories, this), NEWSBLUR.app.taskbar_info.show_stories_error);
|
|
|
|
},
|
|
|
|
|
|
|
|
post_load_stories: function() {
|
2016-12-01 14:27:18 -08:00
|
|
|
this.fill_out();
|
|
|
|
},
|
|
|
|
|
|
|
|
fill_out: function() {
|
|
|
|
var visible = NEWSBLUR.assets.dashboard_stories.visible().length;
|
|
|
|
if (visible >= 5 || this.page > 10) return;
|
2016-11-30 18:53:32 -08:00
|
|
|
|
2016-12-01 14:27:18 -08:00
|
|
|
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);
|
2016-11-29 17:26:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|