Thread skipNotify through addItem

This commit is contained in:
LinuxMercedes 2016-05-26 22:29:12 -05:00
parent 5c9fce9a9d
commit aeb0d7599a
2 changed files with 72 additions and 53 deletions

View file

@ -358,8 +358,8 @@ Zotero.Collection.prototype._finalizeSave = Zotero.Promise.coroutine(function* (
* @param {Number} itemID * @param {Number} itemID
* @return {Promise} * @return {Promise}
*/ */
Zotero.Collection.prototype.addItem = function (itemID) { Zotero.Collection.prototype.addItem = function (itemID, options) {
return this.addItems([itemID]); return this.addItems([itemID], options);
} }
@ -371,7 +371,9 @@ Zotero.Collection.prototype.addItem = function (itemID) {
* @param {Number[]} itemIDs * @param {Number[]} itemIDs
* @return {Promise} * @return {Promise}
*/ */
Zotero.Collection.prototype.addItems = Zotero.Promise.coroutine(function* (itemIDs) { Zotero.Collection.prototype.addItems = Zotero.Promise.coroutine(function* (itemIDs, options = {}) {
options.skipDateModifiedUpdate = true;
if (!itemIDs || !itemIDs.length) { if (!itemIDs || !itemIDs.length) {
return; return;
} }
@ -389,9 +391,7 @@ Zotero.Collection.prototype.addItems = Zotero.Promise.coroutine(function* (itemI
let item = this.ChildObjects.get(itemID); let item = this.ChildObjects.get(itemID);
item.addToCollection(this.id); item.addToCollection(this.id);
yield item.save({ yield item.save(options);
skipDateModifiedUpdate: true
});
} }
yield this.loadDataType('childItems'); yield this.loadDataType('childItems');

View file

@ -1396,9 +1396,11 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
let newParentItemNotifierData = {}; let newParentItemNotifierData = {};
//newParentItemNotifierData[newParentItem.id] = {}; //newParentItemNotifierData[newParentItem.id] = {};
Zotero.Notifier.queue( if (!env.options.skipNotifier) {
'modify', 'item', parentItemID, newParentItemNotifierData, env.options.notifierQueue Zotero.Notifier.queue(
); 'modify', 'item', parentItemID, newParentItemNotifierData, env.options.notifierQueue
);
}
switch (Zotero.ItemTypes.getName(itemTypeID)) { switch (Zotero.ItemTypes.getName(itemTypeID)) {
case 'note': case 'note':
@ -1422,13 +1424,15 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
let newParentItemNotifierData = {}; let newParentItemNotifierData = {};
//newParentItemNotifierData[newParentItem.id] = {}; //newParentItemNotifierData[newParentItem.id] = {};
Zotero.Notifier.queue( if (!env.options.skipNotifier) {
'modify', Zotero.Notifier.queue(
'item', 'modify',
parentItemID, 'item',
newParentItemNotifierData, parentItemID,
env.options.notifierQueue newParentItemNotifierData,
); env.options.notifierQueue
);
}
} }
let oldParentKey = this._previousData.parentKey; let oldParentKey = this._previousData.parentKey;
@ -1438,13 +1442,15 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
if (oldParentItemID) { if (oldParentItemID) {
let oldParentItemNotifierData = {}; let oldParentItemNotifierData = {};
//oldParentItemNotifierData[oldParentItemID] = {}; //oldParentItemNotifierData[oldParentItemID] = {};
Zotero.Notifier.queue( if (!env.options.skipNotifier) {
'modify', Zotero.Notifier.queue(
'item', 'modify',
oldParentItemID, 'item',
oldParentItemNotifierData, oldParentItemID,
env.options.notifierQueue oldParentItemNotifierData,
); env.options.notifierQueue
);
}
} }
else { else {
Zotero.debug("Old source item " + oldParentKey Zotero.debug("Old source item " + oldParentKey
@ -1465,13 +1471,15 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
parentItem.addToCollection(changedCollections[i]); parentItem.addToCollection(changedCollections[i]);
this.removeFromCollection(changedCollections[i]); this.removeFromCollection(changedCollections[i]);
Zotero.Notifier.queue( if (!env.options.skipNotifier) {
'remove', Zotero.Notifier.queue(
'collection-item', 'remove',
changedCollections[i] + '-' + this.id, 'collection-item',
{}, changedCollections[i] + '-' + this.id,
env.options.notifierQueue {},
); env.options.notifierQueue
);
}
} }
let parentOptions = { let parentOptions = {
skipDateModifiedUpdate: true skipDateModifiedUpdate: true
@ -1536,9 +1544,11 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
yield Zotero.DB.queryAsync(sql, itemID); yield Zotero.DB.queryAsync(sql, itemID);
// Refresh trash // Refresh trash
Zotero.Notifier.queue('refresh', 'trash', this.libraryID, {}, env.options.notifierQueue); if (!env.options.skipNotifier) {
if (this._deleted) { Zotero.Notifier.queue('refresh', 'trash', this.libraryID, {}, env.options.notifierQueue);
Zotero.Notifier.queue('trash', 'item', this.id, {}, env.options.notifierQueue); if (this._deleted) {
Zotero.Notifier.queue('trash', 'item', this.id, {}, env.options.notifierQueue);
}
} }
if (parentItemID) { if (parentItemID) {
@ -1658,9 +1668,11 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
tag: tag.tag, tag: tag.tag,
type: tagType type: tagType
}; };
Zotero.Notifier.queue( if (!env.options.skipNotifier) {
'add', 'item-tag', this.id + '-' + tagID, notifierData, env.options.notifierQueue Zotero.Notifier.queue(
); 'add', 'item-tag', this.id + '-' + tagID, notifierData, env.options.notifierQueue
);
}
} }
if (toRemove.length) { if (toRemove.length) {
@ -1674,9 +1686,12 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
libraryID: this.libraryID, libraryID: this.libraryID,
tag: tag.tag tag: tag.tag
}; };
Zotero.Notifier.queue(
'remove', 'item-tag', this.id + '-' + tagID, notifierData, env.options.notifierQueue if (!env.options.skipNotifier) {
); Zotero.Notifier.queue(
'remove', 'item-tag', this.id + '-' + tagID, notifierData, env.options.notifierQueue
);
}
} }
Zotero.Prefs.set('purge.tags', true); Zotero.Prefs.set('purge.tags', true);
} }
@ -1709,13 +1724,15 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
+ "(collectionID, itemID, orderIndex) VALUES (?, ?, ?)"; + "(collectionID, itemID, orderIndex) VALUES (?, ?, ?)";
yield Zotero.DB.queryAsync(sql, [collectionID, this.id, orderIndex]); yield Zotero.DB.queryAsync(sql, [collectionID, this.id, orderIndex]);
Zotero.Notifier.queue( if (!env.options.skipNotifier) {
'add', Zotero.Notifier.queue(
'collection-item', 'add',
collectionID + '-' + this.id, 'collection-item',
{}, collectionID + '-' + this.id,
env.options.notifierQueue {},
); env.options.notifierQueue
);
}
} }
// Add this item to any loaded collections' cached item lists after commit // Add this item to any loaded collections' cached item lists after commit
@ -1735,13 +1752,15 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
for (let i=0; i<toRemove.length; i++) { for (let i=0; i<toRemove.length; i++) {
let collectionID = toRemove[i]; let collectionID = toRemove[i];
Zotero.Notifier.queue( if (!env.options.skipNotifier) {
'remove', Zotero.Notifier.queue(
'collection-item', 'remove',
collectionID + '-' + this.id, 'collection-item',
{}, collectionID + '-' + this.id,
env.options.notifierQueue {},
); env.options.notifierQueue
);
}
} }
// Remove this item from any loaded collections' cached item lists after commit // Remove this item from any loaded collections' cached item lists after commit