From 9318d2ad3eb0fef291e3ebcdefdcdfa02ed1209a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 8 Aug 2009 15:55:28 +0000 Subject: [PATCH] Fix some collection bugs in data layer, thanks to MozMill/Ben --- chrome/content/zotero/xpcom/data/collection.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/collection.js b/chrome/content/zotero/xpcom/data/collection.js index 5c9a0eb0a..8968b9dd5 100644 --- a/chrome/content/zotero/xpcom/data/collection.js +++ b/chrome/content/zotero/xpcom/data/collection.js @@ -221,12 +221,15 @@ Zotero.Collection.prototype.loadFromRow = function(row) { this._hasChildCollections = !!row.hasChildCollections; this._childItemsLoaded = false; this._hasChildItems = !!row.hasChildItems; - this._loadChildItems(); } Zotero.Collection.prototype.isEmpty = function() { - return !(parseInt(this._hasChildCollections)) && !(parseInt(this._hasChildItems)); + if (this._hasChildCollections == undefined) { + this.hasChildCollections(); + } + + return !(this._hasChildCollections || this._hasChildItems); } Zotero.Collection.prototype.hasChildCollections = function() { @@ -245,7 +248,7 @@ Zotero.Collection.prototype.hasChildCollections = function() { } Zotero.Collection.prototype.hasChildItems = function() { - return !!(parseInt(this._hasChildItems)); + return !!this._hasChildItems; } /** @@ -696,12 +699,16 @@ Zotero.Collection.prototype.addItems = function(itemIDs) { catch(e) { throw (e + ' [ERROR: ' + Zotero.DB.getLastErrorString() + ']'); } + + Zotero.Notifier.trigger('add', 'collection-item', this.id + '-' + itemID); } sql = "UPDATE collections SET dateModified=?, clientDateModified=? WHERE collectionID=?"; Zotero.DB.query(sql, [Zotero.DB.transactionDateTime, Zotero.DB.transactionDateTime, this.id]); Zotero.DB.commitTransaction(); + + Zotero.Collections.reload(this.id); } @@ -718,6 +725,9 @@ Zotero.Collection.prototype.removeItem = function(itemID) { return false; } } + else { + return false; + } Zotero.DB.beginTransaction();