Allow extra data for single-object notifications to be passed directly
Previous it had to be keyed by id (and still can be, but if there's only a single id the notifier will now key it automatically)
This commit is contained in:
parent
b785a3bfce
commit
8499ec6211
4 changed files with 15 additions and 10 deletions
|
@ -362,7 +362,7 @@ Zotero.Collection.prototype._finalizeSave = Zotero.Promise.coroutine(function* (
|
|||
Zotero.Notifier.trigger('add', 'collection', this.id);
|
||||
}
|
||||
else {
|
||||
Zotero.Notifier.trigger('modify', 'collection', this.id, this._previousData);
|
||||
Zotero.Notifier.trigger('modify', 'collection', this.id, { changed: this._previousData });
|
||||
}
|
||||
|
||||
// Invalidate cached child collections
|
||||
|
|
|
@ -1218,9 +1218,7 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
|
|||
sqlValues.push(parseInt(itemID));
|
||||
yield Zotero.DB.queryAsync(sql, sqlValues);
|
||||
|
||||
var notifierData = {};
|
||||
notifierData[itemID] = { changed: this._previousData };
|
||||
Zotero.Notifier.trigger('modify', 'item', itemID, notifierData);
|
||||
Zotero.Notifier.trigger('modify', 'item', itemID, { changed: this._previousData });
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -138,11 +138,18 @@ Zotero.Notifier = new function(){
|
|||
// Merge extraData keys
|
||||
if (extraData) {
|
||||
Zotero.debug("ADDING EXTRA DATA");
|
||||
for (var dataID in extraData) {
|
||||
Zotero.debug(dataID);
|
||||
if (extraData[dataID]) {
|
||||
Zotero.debug("YES");
|
||||
_queue[type][event].data[dataID] = extraData[dataID];
|
||||
// If just a single id, extra data can be keyed by id or passed directly
|
||||
if (ids.length == 1) {
|
||||
let id = ids[0];
|
||||
_queue[type][event].data[id] = extraData[id] ? extraData[id] : extraData;
|
||||
}
|
||||
// For multiple ids, check for data keyed by the id
|
||||
else {
|
||||
for (let i = 0; i < ids.length; i++) {
|
||||
let id = ids[i];
|
||||
if (extraData[id]) {
|
||||
_queue[type][event].data[id] = extraData[id];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -260,7 +260,7 @@ Zotero.Search.prototype._finalizeSave = Zotero.Promise.coroutine(function* (env)
|
|||
Zotero.Notifier.trigger('add', 'search', this.id);
|
||||
}
|
||||
else {
|
||||
Zotero.Notifier.trigger('modify', 'search', this.id, this._previousData);
|
||||
Zotero.Notifier.trigger('modify', 'search', this.id, { changed: this._previousData });
|
||||
}
|
||||
|
||||
if (isNew && Zotero.Libraries.isGroupLibrary(this.libraryID)) {
|
||||
|
|
Loading…
Reference in a new issue