From 3715f2c89ec7b9e91a802dd3f6d347ba1877a2ab Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 8 Jun 2006 20:41:37 +0000 Subject: [PATCH] - Send a 'modify' to collections in addItem() and removeItem() when collections become or stop being empty - Send a 'delete' rather than a 'remove' to itemViews when items are actually deleted (removals from collections still get 'remove' unless it's part of a collection erase) --- .../chromeFiles/content/scholar/xpcom/data_access.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/xpcom/data_access.js b/chrome/chromeFiles/content/scholar/xpcom/data_access.js index ce88200261..d5311beca0 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/data_access.js +++ b/chrome/chromeFiles/content/scholar/xpcom/data_access.js @@ -712,7 +712,7 @@ Scholar.Item.prototype.erase = function(){ // If we're not in the middle of a larger commit, trigger the notifier now if (!Scholar.DB.transactionInProgress()){ - Scholar.Notifier.trigger('remove', 'item', this.getID()); + Scholar.Notifier.trigger('delete', 'item', this.getID()); } } @@ -1189,7 +1189,12 @@ Scholar.Collection.prototype.addItem = function(itemID){ Scholar.DB.commitTransaction(); this._childItems.set(itemID); - this._hasChildItems = true; + + // If this was previously empty, update and send a notification to the tree + if (!this._hasChildItems){ + this._hasChildItems = true; + Scholar.Notifier.trigger('modify', 'collections', this.getID()); + } Scholar.Notifier.trigger('add', 'item', itemID); } @@ -1228,6 +1233,7 @@ Scholar.Collection.prototype.removeItem = function(itemID){ // If this was the last item, set collection to empty if (!this._childItems.length){ this._hasChildItems = false; + Scholar.Notifier.trigger('modify', 'collections', this.getID()); } Scholar.Notifier.trigger('remove', 'item', itemID); @@ -1299,7 +1305,7 @@ Scholar.Collection.prototype.erase = function(deleteItems){ Scholar.Notifier.trigger('remove', 'collection', collections); if (items.length){ - Scholar.Notifier.trigger('remove', 'item', items); + Scholar.Notifier.trigger('delete', 'item', items); } }