Fix number key assignment of colored tag without any items

Fixes #1464
This commit is contained in:
Dan Stillman 2019-10-26 14:35:55 -04:00
parent e7d0e282e7
commit d8b5f30504

View file

@ -725,20 +725,15 @@ Zotero.Tags = new function() {
return;
}
// Color setting can exist without tag. If missing, we have to add the tag.
var tagID = this.getID(tagName);
// If there's a color setting but no matching tag, don't throw
// an error (though ideally this wouldn't be possible).
if (!tagID) {
return;
}
return Zotero.DB.executeTransaction(function* () {
// Base our action on the first item. If it has the tag,
// remove the tag from all items. If it doesn't, add it to all.
var firstItem = items[0];
// Remove from all items
if (firstItem.hasTag(tagName)) {
if (tagID && firstItem.hasTag(tagName)) {
for (let i=0; i<items.length; i++) {
let item = items[i];
item.removeTag(tagName);