mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-31 21:41:33 +00:00
Wrapping dashboard stories in a IIFE to keep dashboard stories and count in a throttled function.
This commit is contained in:
parent
a52be087df
commit
b76e35d223
3 changed files with 10 additions and 8 deletions
|
@ -831,11 +831,13 @@ NEWSBLUR.AssetModel = Backbone.Router.extend({
|
|||
var self = this;
|
||||
|
||||
|
||||
var pre_callback = function(data) {
|
||||
dashboard_stories.add(data.stories, {silent: true});
|
||||
dashboard_stories.limit_visible_on_dashboard(dashboard_count);
|
||||
dashboard_stories.trigger('reset', {added: 1});
|
||||
};
|
||||
var pre_callback = (function (dashboard_stories, dashboard_count) {
|
||||
return function (data) {
|
||||
dashboard_stories.add(data.stories, { silent: true });
|
||||
dashboard_stories.limit_visible_on_dashboard(dashboard_count);
|
||||
dashboard_stories.trigger('reset', { added: 1 });
|
||||
};
|
||||
})(dashboard_stories, dashboard_count);
|
||||
|
||||
if (!('hashes' in this.queued_realtime_stories)) { this.queued_realtime_stories['hashes'] = []; }
|
||||
this.queued_realtime_stories['hashes'].push(story_hash);
|
||||
|
|
|
@ -75,7 +75,7 @@ NEWSBLUR.Models.Story = Backbone.Model.extend({
|
|||
|
||||
image_url: function(index) {
|
||||
if (!index) index = 0;
|
||||
if (this.get('image_urls').length >= index+1) {
|
||||
if (this.get('image_urls') && this.get('image_urls').length >= index+1) {
|
||||
var url = this.get('image_urls')[index];
|
||||
if (window.location.protocol == 'https:' &&
|
||||
_.str.startsWith(url, "http://")) {
|
||||
|
|
|
@ -418,9 +418,10 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
|
|||
return;
|
||||
}
|
||||
|
||||
var dashboard_count = parseInt(NEWSBLUR.assets.view_setting(this.model.get('river_id'), 'dashboard_count'), 10);
|
||||
var subs = feed.get('num_subscribers');
|
||||
var delay = subs * 2; // 1,000 subs = 2 seconds
|
||||
console.log(['Fetching dashboard story', this.model.get('river_id'), story_hash, delay + 'ms delay']);
|
||||
// console.log(['Fetching dashboard story', this.model.get('river_id'), story_hash, delay + 'ms delay', dashboard_count]);
|
||||
|
||||
if (NEWSBLUR.reader.flags['deactivate_new_dashboard_story']) {
|
||||
console.log(['...NOT Fetching dashboard story', this.model.get('river_id')]);
|
||||
|
@ -428,7 +429,6 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
|
|||
}
|
||||
|
||||
// _.delay(_.bind(function() {
|
||||
var dashboard_count = parseInt(NEWSBLUR.assets.view_setting(this.model.get('river_id'), 'dashboard_count'), 10);
|
||||
NEWSBLUR.assets.add_dashboard_story(story_hash, this.options.dashboard_stories, dashboard_count);
|
||||
// }, this), Math.random() * delay);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue