mirror of
https://github.com/viq/NewsBlur.git
synced 2025-08-31 22:20:12 +00:00
Merge branch 'master' into readstories
* master: Fixing view destroy for comments. Fixing a number of big memory leaks. Fixing story intelligence trainer.
This commit is contained in:
commit
939a487ebb
9 changed files with 77 additions and 8 deletions
|
@ -2276,6 +2276,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feed) {
|
if (feed) {
|
||||||
|
if (NEWSBLUR.app.story_unread_counter) {
|
||||||
|
NEWSBLUR.app.story_unread_counter.destroy();
|
||||||
|
}
|
||||||
NEWSBLUR.app.story_unread_counter = new NEWSBLUR.Views.UnreadCount({
|
NEWSBLUR.app.story_unread_counter = new NEWSBLUR.Views.UnreadCount({
|
||||||
model: feed
|
model: feed
|
||||||
}).render();
|
}).render();
|
||||||
|
@ -2287,6 +2290,9 @@
|
||||||
} else {
|
} else {
|
||||||
collection = folder.folder_view.collection;
|
collection = folder.folder_view.collection;
|
||||||
}
|
}
|
||||||
|
if (NEWSBLUR.app.story_unread_counter) {
|
||||||
|
NEWSBLUR.app.story_unread_counter.destroy();
|
||||||
|
}
|
||||||
NEWSBLUR.app.story_unread_counter = new NEWSBLUR.Views.UnreadCount({
|
NEWSBLUR.app.story_unread_counter = new NEWSBLUR.Views.UnreadCount({
|
||||||
collection: collection
|
collection: collection
|
||||||
}).render();
|
}).render();
|
||||||
|
@ -4945,6 +4951,14 @@
|
||||||
self.open_feed_intelligence_modal(1, feed_id, false);
|
self.open_feed_intelligence_modal(1, feed_id, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-story-train' }, function($t, $p){
|
||||||
|
e.preventDefault();
|
||||||
|
if (!$t.hasClass('NB-disabled')) {
|
||||||
|
var feed_id = $t.parents('.NB-menu-manage').data('feed_id');
|
||||||
|
var story_id = $t.parents('.NB-menu-manage').data('story_id');
|
||||||
|
self.open_story_trainer(story_id, feed_id);
|
||||||
|
}
|
||||||
|
});
|
||||||
$.targetIs(e, { tagSelector: '.NB-menu-manage-feed-recommend' }, function($t, $p){
|
$.targetIs(e, { tagSelector: '.NB-menu-manage-feed-recommend' }, function($t, $p){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var feed_id = $t.parents('.NB-menu-manage').data('feed_id');
|
var feed_id = $t.parents('.NB-menu-manage').data('feed_id');
|
||||||
|
|
|
@ -171,6 +171,9 @@ NEWSBLUR.Views.FeedTitleView = Backbone.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
render_counts: function() {
|
render_counts: function() {
|
||||||
|
if (this.counts_view) {
|
||||||
|
this.counts_view.destroy();
|
||||||
|
}
|
||||||
this.counts_view = new NEWSBLUR.Views.UnreadCount({model: this.model}).render();
|
this.counts_view = new NEWSBLUR.Views.UnreadCount({model: this.model}).render();
|
||||||
this.$('.feed_counts').html(this.counts_view.el);
|
this.$('.feed_counts').html(this.counts_view.el);
|
||||||
if (this.options.type == 'story') {
|
if (this.options.type == 'story') {
|
||||||
|
|
|
@ -217,6 +217,9 @@ NEWSBLUR.Views.Folder = Backbone.View.extend({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.folder_count) {
|
||||||
|
this.folder_count.destroy();
|
||||||
|
}
|
||||||
this.folder_count = new NEWSBLUR.Views.UnreadCount({
|
this.folder_count = new NEWSBLUR.Views.UnreadCount({
|
||||||
collection: this.collection
|
collection: this.collection
|
||||||
}).render();
|
}).render();
|
||||||
|
|
|
@ -60,9 +60,13 @@ NEWSBLUR.Views.Sidebar = Backbone.View.extend({
|
||||||
|
|
||||||
show_counts: function(options) {
|
show_counts: function(options) {
|
||||||
var $header = NEWSBLUR.reader.$s.$river_blurblogs_header;
|
var $header = NEWSBLUR.reader.$s.$river_blurblogs_header;
|
||||||
var $counts = new NEWSBLUR.Views.UnreadCount({
|
if (this.unread_count) {
|
||||||
|
this.unread_count.destroy();
|
||||||
|
}
|
||||||
|
this.unread_count = new NEWSBLUR.Views.UnreadCount({
|
||||||
collection: NEWSBLUR.assets.social_feeds
|
collection: NEWSBLUR.assets.social_feeds
|
||||||
}).render().$el;
|
}).render();
|
||||||
|
var $counts = this.unread_count.$el;
|
||||||
|
|
||||||
if (this.options.feedbar) {
|
if (this.options.feedbar) {
|
||||||
this.$('.NB-story-title-indicator-count').html($counts.clone());
|
this.$('.NB-story-title-indicator-count').html($counts.clone());
|
||||||
|
|
|
@ -24,6 +24,10 @@ NEWSBLUR.Views.StoryCommentsView = Backbone.View.extend({
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
destroy: function() {
|
||||||
|
this.remove();
|
||||||
|
},
|
||||||
|
|
||||||
render_teaser: function() {
|
render_teaser: function() {
|
||||||
if (!this.model.get('share_count')) return;
|
if (!this.model.get('share_count')) return;
|
||||||
|
|
||||||
|
|
|
@ -252,7 +252,8 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
|
||||||
var $original_comments = this.$('.NB-feed-story-comments-container,.NB-feed-story-comments');
|
var $original_comments = this.$('.NB-feed-story-comments-container,.NB-feed-story-comments');
|
||||||
var $original_shares = this.$('.NB-feed-story-shares-container,.NB-feed-story-shares');
|
var $original_shares = this.$('.NB-feed-story-shares-container,.NB-feed-story-shares');
|
||||||
if (this.model.get("comment_count") || this.model.get("share_count")) {
|
if (this.model.get("comment_count") || this.model.get("share_count")) {
|
||||||
var $comments = new NEWSBLUR.Views.StoryCommentsView({model: this.model}).render().el;
|
this.comments_view = new NEWSBLUR.Views.StoryCommentsView({model: this.model}).render();
|
||||||
|
var $comments = this.comments_view.el;
|
||||||
$original_comments.replaceWith($comments);
|
$original_comments.replaceWith($comments);
|
||||||
var $shares = $('.NB-story-comments-shares-teaser-wrapper', $comments);
|
var $shares = $('.NB-story-comments-shares-teaser-wrapper', $comments);
|
||||||
$original_shares.replaceWith($shares);
|
$original_shares.replaceWith($shares);
|
||||||
|
@ -263,9 +264,13 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
|
// console.log(["destroy story detail", this.model.get('story_title')]);
|
||||||
clearTimeout(this.truncate_delay_function);
|
clearTimeout(this.truncate_delay_function);
|
||||||
this.images_to_load = null;
|
this.images_to_load = null;
|
||||||
this.model.unbind(null, null, this);
|
this.model.unbind(null, null, this);
|
||||||
|
if (this.collection) this.collection.unbind(null, null, this);
|
||||||
|
// this.sideoptions_view.destroy();
|
||||||
|
if (this.comments_view) this.comments_view.destroy();
|
||||||
delete this.model.inline_story_detail_view;
|
delete this.model.inline_story_detail_view;
|
||||||
this.remove();
|
this.remove();
|
||||||
},
|
},
|
||||||
|
|
|
@ -88,6 +88,19 @@ NEWSBLUR.Views.StoryTitleView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
destroy: function() {
|
||||||
|
// console.log(["destroy story title", this.model.get('story_title')]);
|
||||||
|
if (this.text_view) {
|
||||||
|
this.text_view.destroy();
|
||||||
|
}
|
||||||
|
if (this.story_detail) {
|
||||||
|
this.story_detail.destroy();
|
||||||
|
}
|
||||||
|
this.model.unbind(null, null, this);
|
||||||
|
this.collection.unbind(null, null, this);
|
||||||
|
this.remove();
|
||||||
|
},
|
||||||
|
|
||||||
destroy_inline_story_detail: function() {
|
destroy_inline_story_detail: function() {
|
||||||
if (this.story_detail) {
|
if (this.story_detail) {
|
||||||
this.story_detail.destroy();
|
this.story_detail.destroy();
|
||||||
|
|
|
@ -16,6 +16,7 @@ NEWSBLUR.Views.StoryTitlesView = Backbone.View.extend({
|
||||||
this.collection.bind('no_more_stories', this.check_premium_river, this);
|
this.collection.bind('no_more_stories', this.check_premium_river, this);
|
||||||
this.collection.bind('no_more_stories', this.check_premium_search, this);
|
this.collection.bind('no_more_stories', this.check_premium_search, this);
|
||||||
NEWSBLUR.reader.$s.$story_titles.scroll(this.scroll);
|
NEWSBLUR.reader.$s.$story_titles.scroll(this.scroll);
|
||||||
|
this.stories = [];
|
||||||
},
|
},
|
||||||
|
|
||||||
// ==========
|
// ==========
|
||||||
|
@ -23,13 +24,18 @@ NEWSBLUR.Views.StoryTitlesView = Backbone.View.extend({
|
||||||
// ==========
|
// ==========
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
this.clear();
|
||||||
NEWSBLUR.reader.$s.$story_titles.scrollTop(0);
|
NEWSBLUR.reader.$s.$story_titles.scrollTop(0);
|
||||||
var collection = this.collection;
|
var collection = this.collection;
|
||||||
var $stories = this.collection.map(function(story) {
|
var stories = this.collection.map(function(story) {
|
||||||
return new NEWSBLUR.Views.StoryTitleView({
|
return new NEWSBLUR.Views.StoryTitleView({
|
||||||
model: story,
|
model: story,
|
||||||
collection: collection
|
collection: collection
|
||||||
}).render().el;
|
}).render();
|
||||||
|
});
|
||||||
|
this.stories = stories;
|
||||||
|
var $stories = _.map(stories, function(story) {
|
||||||
|
return story.el;
|
||||||
});
|
});
|
||||||
this.$el.html($stories);
|
this.$el.html($stories);
|
||||||
this.end_loading();
|
this.end_loading();
|
||||||
|
@ -39,19 +45,27 @@ NEWSBLUR.Views.StoryTitlesView = Backbone.View.extend({
|
||||||
add: function(options) {
|
add: function(options) {
|
||||||
var collection = this.collection;
|
var collection = this.collection;
|
||||||
if (options.added) {
|
if (options.added) {
|
||||||
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) {
|
||||||
if (story.story_title_view) return;
|
if (story.story_title_view) return;
|
||||||
return new NEWSBLUR.Views.StoryTitleView({
|
return new NEWSBLUR.Views.StoryTitleView({
|
||||||
model: story,
|
model: story,
|
||||||
collection: collection
|
collection: collection
|
||||||
}).render().el;
|
}).render();
|
||||||
}));
|
}));
|
||||||
|
this.stories = this.stories.concat(stories);
|
||||||
|
var $stories = _.map(stories, function(story) {
|
||||||
|
return story.el;
|
||||||
|
});
|
||||||
this.$el.append($stories);
|
this.$el.append($stories);
|
||||||
}
|
}
|
||||||
this.end_loading();
|
this.end_loading();
|
||||||
this.fill_out();
|
this.fill_out();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clear: function() {
|
||||||
|
_.invoke(this.stories, 'destroy');
|
||||||
|
},
|
||||||
|
|
||||||
append_river_premium_only_notification: function() {
|
append_river_premium_only_notification: function() {
|
||||||
var $notice = $.make('div', { className: 'NB-feed-story-premium-only' }, [
|
var $notice = $.make('div', { className: 'NB-feed-story-premium-only' }, [
|
||||||
$.make('div', { className: 'NB-feed-story-premium-only-text'}, [
|
$.make('div', { className: 'NB-feed-story-premium-only-text'}, [
|
||||||
|
|
|
@ -48,6 +48,15 @@ NEWSBLUR.Views.UnreadCount = Backbone.View.extend({
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
destroy: function() {
|
||||||
|
if (this.model) {
|
||||||
|
this.model.unbind(null, null, this);
|
||||||
|
} else if (this.collection) {
|
||||||
|
this.collection.unbind(null, null, this);
|
||||||
|
}
|
||||||
|
this.remove();
|
||||||
|
},
|
||||||
|
|
||||||
template: _.template('\
|
template: _.template('\
|
||||||
<div class="<%= unread_class %>">\
|
<div class="<%= unread_class %>">\
|
||||||
<span class="unread_count unread_count_positive <% if (ps) { %>unread_count_full<% } else { %>unread_count_empty<% } %>">\
|
<span class="unread_count unread_count_positive <% if (ps) { %>unread_count_full<% } else { %>unread_count_empty<% } %>">\
|
||||||
|
|
Loading…
Add table
Reference in a new issue