Using parent folder to update all parent folders on read story.

This commit is contained in:
Samuel Clay 2012-08-27 14:50:36 -07:00
parent 3939f29d87
commit 11a2f735a2
2 changed files with 9 additions and 2 deletions

View file

@ -19,6 +19,9 @@ NEWSBLUR.Models.Feed = Backbone.Model.extend({
update_folder_counts: function() {
_.each(this.folders, function(folder) {
folder.trigger('change:counts');
if (folder.parent_folder) {
folder.parent_folder.trigger('change:counts');
}
});
},

View file

@ -4,7 +4,7 @@ NEWSBLUR.Models.FeedOrFolder = Backbone.Model.extend({
if (_.isNumber(model)) {
this.feed = NEWSBLUR.assets.feeds.get(model);
// The feed needs to exists as a model as well. Otherwise, chuck it.
// The feed needs to exists as a model as well. Otherwise, toss it.
if (this.feed) {
this.set('is_feed', true);
}
@ -14,7 +14,10 @@ NEWSBLUR.Models.FeedOrFolder = Backbone.Model.extend({
this.set('is_folder', true);
this.set('folder_title', title);
this.folder_views = [];
this.folders = new NEWSBLUR.Collections.Folders([], {title: title});
this.folders = new NEWSBLUR.Collections.Folders([], {
title: title,
parent_folder: this.collection
});
this.folders.reset(_.compact(children));
}
},
@ -93,6 +96,7 @@ NEWSBLUR.Collections.Folders = Backbone.Collection.extend({
initialize: function(models, options) {
this.options = options || {};
this.parent_folder = options && options.parent_folder;
this.comparator = NEWSBLUR.Collections.Folders.comparator;
},