mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Cascading new story fetches on front-end to prevent stampede.
This commit is contained in:
parent
1facf2db1c
commit
9e78e499b2
1 changed files with 9 additions and 2 deletions
|
@ -143,8 +143,15 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({
|
|||
}
|
||||
}
|
||||
|
||||
console.log(['Fetching dashboard story', story_hash]);
|
||||
NEWSBLUR.assets.add_dashboard_story(story_hash);
|
||||
var feed_id = story_hash.split(':')[0];
|
||||
var feed = NEWSBLUR.assets.get_feed(feed_id);
|
||||
var subs = feed.get('num_subscribers');
|
||||
var delay = subs * 2; // 1,000 subs = 2 seconds
|
||||
console.log(['Fetching dashboard story', story_hash, delay + 'ms delay']);
|
||||
|
||||
_.delay(function() {
|
||||
NEWSBLUR.assets.add_dashboard_story(story_hash);
|
||||
}, Math.random() * delay);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue