diff --git a/chrome/content/zotero/xpcom/data/group.js b/chrome/content/zotero/xpcom/data/group.js index 71b8a9948..ae24b056b 100644 --- a/chrome/content/zotero/xpcom/data/group.js +++ b/chrome/content/zotero/xpcom/data/group.js @@ -221,11 +221,7 @@ Zotero.Group.prototype.save = Zotero.Promise.coroutine(function* () { if (isNew) { let { id: libraryID } = yield Zotero.Libraries.add( - 'group', - { - editable: this.editable, - filesEditable: this.filesEditable - } + 'group', this.editable, this.filesEditable ); sqlColumns.push('libraryID'); sqlValues.push(libraryID); diff --git a/chrome/content/zotero/xpcom/data/libraries.js b/chrome/content/zotero/xpcom/data/libraries.js index f324984bc..159d363e8 100644 --- a/chrome/content/zotero/xpcom/data/libraries.js +++ b/chrome/content/zotero/xpcom/data/libraries.js @@ -80,15 +80,12 @@ Zotero.Libraries = new function () { /** * @param {String} type - Library type - * @param {Object} [options] - Library properties to set - * @param {Boolean} [options.editable] - * @param {Boolean} [options.filesEditable] + * @param {Boolean} editable + * @param {Boolean} filesEditable */ - this.add = Zotero.Promise.coroutine(function* (type, options) { + this.add = Zotero.Promise.coroutine(function* (type, editable, filesEditable) { Zotero.DB.requireTransaction(); - options = options || {}; - switch (type) { case 'group': break; @@ -99,17 +96,14 @@ Zotero.Libraries = new function () { var libraryID = yield Zotero.ID.get('libraries'); - var sql = "INSERT INTO libraries (libraryID, libraryType"; - var params = [libraryID, type]; - if (options.editable) { - sql += ", editable"; - params.push(options.editable ? 1 : 0); - if (options.filesEditable) { - sql += ", filesEditable"; - params.push(options.filesEditable ? 1 : 0); - } - } - sql += ") VALUES (" + params.map(p => "?").join(", ") + ")"; + var sql = "INSERT INTO libraries (libraryID, libraryType, editable, filesEditable) " + + "VALUES (?, ?, ?, ?)"; + var params = [ + libraryID, + type, + editable ? 1 : 0, + filesEditable ? 1 : 0 + ]; yield Zotero.DB.queryAsync(sql, params); // Re-fetch from DB to get auto-filled defaults @@ -236,8 +230,8 @@ Zotero.Libraries = new function () { return { id: row.libraryID, type: row.libraryType, - editable: row.editable, - filesEditable: row.filesEditable, + editable: !!row.editable, + filesEditable: !!row.filesEditable, version: row.version, lastSyncTime: row.lastsync != 0 ? new Date(row.lastsync * 1000) : false };