From da754eca8440fdf7859b6c212b5ecc1c4843bc91 Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Thu, 1 Dec 2016 15:06:19 -0800 Subject: [PATCH] Syncing read status on dashboard to river. --- media/js/newsblur/views/dashboard_river.js | 17 +++++++++++++++++ templates/reader/dashboard.xhtml | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/media/js/newsblur/views/dashboard_river.js b/media/js/newsblur/views/dashboard_river.js index da412f266..1d7462f4d 100644 --- a/media/js/newsblur/views/dashboard_river.js +++ b/media/js/newsblur/views/dashboard_river.js @@ -18,8 +18,12 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({ on_dashboard: true }); this.page = 1; + this.cache = { + story_hashes: [] + }; NEWSBLUR.assets.feeds.bind('reset', _.bind(this.load_stories, this)); + NEWSBLUR.assets.stories.bind('change:read_status', this.check_read_stories, this); }, feeds: function() { @@ -53,6 +57,7 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({ post_load_stories: function() { this.fill_out(); + this.cache.story_hashes = NEWSBLUR.assets.dashboard_stories.pluck('story_hash'); }, fill_out: function() { @@ -68,6 +73,18 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({ 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); + }, + + check_read_stories: function(story) { + console.log(['story read', story, story.get('story_hash'), story.get('read_status')]); + if (!_.contains(this.cache.story_hashes, story.get('story_hash'))) return; + var dashboard_story = NEWSBLUR.assets.dashboard_stories.get_by_story_hash(story.get('story_hash')); + if (!dashboard_story) { + console.log(['Error: missing story on dashboard', story, this.cache.story_hashes]); + return; + } + + dashboard_story.set('read_status', story.get('read_status')); } }); \ No newline at end of file diff --git a/templates/reader/dashboard.xhtml b/templates/reader/dashboard.xhtml index e0ebd26b6..254f1c0c2 100644 --- a/templates/reader/dashboard.xhtml +++ b/templates/reader/dashboard.xhtml @@ -71,7 +71,8 @@ {% if not user_profile.hide_getting_started %} {% render_getting_started %} {% endif %} - + + {% if user.is_staff %}
@@ -84,6 +85,7 @@
+ {% endif %} {% render_features_module %}