Implement library.isGroup property, which was never properly implemented
And since `Zotero.Libraries.isGroupLibrary()` just checked that property, that hasn't worked either since `isGroup` was added in 2015. There's no test for `.isGroup`, and the test for `isGroupLibrary()` used `if()` instead of `it()`, so it never actually ran. Also: - Remove old code block in search.js that called `isGroupLibrary()`. Since `isGroupLibrary()` didn't work, this block was unused, and its logic was previously added elsewhere.
This commit is contained in:
parent
689da34094
commit
fb01339c6b
3 changed files with 9 additions and 7 deletions
|
@ -147,6 +147,12 @@ Zotero.defineProperty(Zotero.Library.prototype, 'libraryTypeID', {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Zotero.defineProperty(Zotero.Library.prototype, 'isGroup', {
|
||||||
|
get: function () {
|
||||||
|
return this.libraryType == 'group';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Zotero.defineProperty(Zotero.Library.prototype, 'libraryVersion', {
|
Zotero.defineProperty(Zotero.Library.prototype, 'libraryVersion', {
|
||||||
get: function() { return this._get('_libraryVersion'); },
|
get: function() { return this._get('_libraryVersion'); },
|
||||||
set: function(v) { return this._set('_libraryVersion', v); }
|
set: function(v) { return this._set('_libraryVersion', v); }
|
||||||
|
|
|
@ -247,12 +247,6 @@ Zotero.Search.prototype._finalizeSave = Zotero.Promise.coroutine(function* (env)
|
||||||
Zotero.Notifier.queue('modify', 'search', this.id, env.notifierData, env.options.notifierQueue);
|
Zotero.Notifier.queue('modify', 'search', this.id, env.notifierData, env.options.notifierQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (env.isNew && Zotero.Libraries.isGroupLibrary(this.libraryID)) {
|
|
||||||
var groupID = Zotero.Groups.getGroupIDFromLibraryID(this.libraryID);
|
|
||||||
var group = yield Zotero.Groups.get(groupID);
|
|
||||||
group.clearSearchCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!env.skipCache) {
|
if (!env.skipCache) {
|
||||||
yield this.reload();
|
yield this.reload();
|
||||||
// If new, there's no other data we don't have, so we can mark everything as loaded
|
// If new, there's no other data we don't have, so we can mark everything as loaded
|
||||||
|
|
|
@ -187,9 +187,11 @@ describe("Zotero.Libraries", function() {
|
||||||
assert.isFalse(Zotero.Libraries.isGroupLibrary(id), "returns false for " + type + " library");
|
assert.isFalse(Zotero.Libraries.isGroupLibrary(id), "returns false for " + type + " library");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if("should return true for group library", function(){
|
|
||||||
|
it("should return true for group library", function () {
|
||||||
assert.isTrue(Zotero.Libraries.isGroupLibrary(group.libraryID));
|
assert.isTrue(Zotero.Libraries.isGroupLibrary(group.libraryID));
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should throw for invalid library ID", function() {
|
it("should throw for invalid library ID", function() {
|
||||||
assert.throws(Zotero.Libraries.isGroupLibrary.bind(Zotero.Libraries, -1), /^Invalid library ID /);
|
assert.throws(Zotero.Libraries.isGroupLibrary.bind(Zotero.Libraries, -1), /^Invalid library ID /);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue