Prevent setting search .name
to empty value
Prevents bug in zotero-citation plugin (at least on macOS) from creating a search that breaks syncing We were already checking for a missing name in `saveTx()`, but the plugin is saving the same search twice in rapid succession, the second time without a name, and the second attempt clears the search object's name value after the first save's `_initSave()` check and before its SQL write. The second save fails, but the first save goes through without a name, resulting in a sync error. https://forums.zotero.org/discussion/104274/id-1702002152-cannot-sync https://github.com/MuiseDestiny/zotero-citation/issues/31
This commit is contained in:
parent
cadfca7475
commit
33ef7b1641
2 changed files with 13 additions and 1 deletions
|
@ -75,7 +75,12 @@ Zotero.defineProperty(Zotero.Search.prototype, 'key', {
|
|||
});
|
||||
Zotero.defineProperty(Zotero.Search.prototype, 'name', {
|
||||
get: function() { return this._get('name'); },
|
||||
set: function(val) { return this._set('name', val); }
|
||||
set: function (val) {
|
||||
if (!val) {
|
||||
throw new Error("Saved search name cannot be empty");
|
||||
}
|
||||
return this._set('name', val);
|
||||
}
|
||||
});
|
||||
Zotero.defineProperty(Zotero.Search.prototype, 'version', {
|
||||
get: function() { return this._get('version'); },
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
describe("Zotero.Search", function() {
|
||||
describe("#name", function () {
|
||||
it("should fail if empty", async function () {
|
||||
var s = new Zotero.Search();
|
||||
assert.throws(() => s.name = '');
|
||||
});
|
||||
});
|
||||
|
||||
describe("#addCondition()", function () {
|
||||
it("should convert old-style 'collection' condition value", function* () {
|
||||
var col = yield createDataObject('collection');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue