Update some outdated Zotero.Libraries.getType()/getName() calls
This commit is contained in:
parent
3ad6e78d98
commit
e0b5111442
9 changed files with 47 additions and 50 deletions
|
@ -1594,7 +1594,7 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r
|
|||
childFileAttachments: Zotero.Prefs.get('groups.copyChildFileAttachments')
|
||||
};
|
||||
var copyItem = Zotero.Promise.coroutine(function* (item, targetLibraryID, options) {
|
||||
var targetLibraryType = Zotero.Libraries.getType(targetLibraryID);
|
||||
var targetLibraryType = Zotero.Libraries.get(targetLibraryID).libraryType;
|
||||
|
||||
// Check if there's already a copy of this item in the library
|
||||
var linkedItem = yield item.getLinkedItem(targetLibraryID, true);
|
||||
|
@ -2197,7 +2197,7 @@ Zotero.CollectionTreeRow.prototype.isShare = function()
|
|||
// Special
|
||||
Zotero.CollectionTreeRow.prototype.isWithinGroup = function () {
|
||||
return this.ref && !this.isHeader()
|
||||
&& Zotero.Libraries.getType(this.ref.libraryID) == 'group';
|
||||
&& Zotero.Libraries.get(this.ref.libraryID).libraryType == 'group';
|
||||
}
|
||||
|
||||
Zotero.CollectionTreeRow.prototype.isWithinEditableGroup = function () {
|
||||
|
@ -2220,7 +2220,7 @@ Zotero.CollectionTreeRow.prototype.__defineGetter__('editable', function () {
|
|||
return this.ref.editable;
|
||||
}
|
||||
if (this.isCollection() || this.isSearch() || this.isDuplicates() || this.isUnfiled()) {
|
||||
var type = Zotero.Libraries.getType(libraryID);
|
||||
var type = Zotero.Libraries.get(libraryID).libraryType;
|
||||
if (type == 'group') {
|
||||
var groupID = Zotero.Groups.getGroupIDFromLibraryID(libraryID);
|
||||
var group = Zotero.Groups.get(groupID);
|
||||
|
@ -2243,7 +2243,7 @@ Zotero.CollectionTreeRow.prototype.__defineGetter__('filesEditable', function ()
|
|||
return this.ref.filesEditable;
|
||||
}
|
||||
if (this.isCollection() || this.isSearch() || this.isDuplicates() || this.isUnfiled()) {
|
||||
var type = Zotero.Libraries.getType(libraryID);
|
||||
var type = Zotero.Libraries.get(libraryID).libraryType;
|
||||
if (type == 'group') {
|
||||
var groupID = Zotero.Groups.getGroupIDFromLibraryID(libraryID);
|
||||
var group = Zotero.Groups.get(groupID);
|
||||
|
|
|
@ -820,7 +820,7 @@ Zotero.DataObject.prototype.isEditable = function () {
|
|||
|
||||
Zotero.DataObject.prototype.editCheck = function () {
|
||||
if ((this._objectType == 'collection' || this._objectType == 'search')
|
||||
&& Zotero.Libraries.getType(this.libraryID) == 'publications') {
|
||||
&& Zotero.Libraries.get(this.libraryID).libraryType == 'publications') {
|
||||
throw new Error(this._ObjectTypePlural + " cannot be added to My Publications");
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ Zotero.DataObjectUtilities = {
|
|||
* @return {String[]} - An array of DataObject types
|
||||
*/
|
||||
getTypesForLibrary: function (libraryID) {
|
||||
switch (Zotero.Libraries.getType(libraryID)) {
|
||||
switch (Zotero.Libraries.get(libraryID).libraryType) {
|
||||
case 'publications':
|
||||
return ['item'];
|
||||
|
||||
|
|
|
@ -1097,7 +1097,7 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
|
|||
|
||||
var isNew = env.isNew;
|
||||
var options = env.options;
|
||||
var libraryType = env.libraryType = Zotero.Libraries.getType(env.libraryID);
|
||||
var libraryType = env.libraryType = Zotero.Libraries.get(env.libraryID).libraryType;
|
||||
|
||||
var itemTypeID = this.itemTypeID;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ Zotero.Sync.Storage.Local = {
|
|||
},
|
||||
|
||||
getModeForLibrary: function (libraryID) {
|
||||
var libraryType = Zotero.Libraries.getType(libraryID);
|
||||
var libraryType = Zotero.Libraries.get(libraryID).libraryType;
|
||||
switch (libraryType) {
|
||||
case 'user':
|
||||
case 'publications':
|
||||
|
@ -22,7 +22,7 @@ Zotero.Sync.Storage.Local = {
|
|||
},
|
||||
|
||||
setModeForLibrary: function (libraryID, mode) {
|
||||
var libraryType = Zotero.Libraries.getType(libraryID);
|
||||
var libraryType = Zotero.Libraries.get(libraryID).libraryType;
|
||||
|
||||
if (libraryType != 'user') {
|
||||
throw new Error(`Cannot set storage mode for ${libraryType} library`);
|
||||
|
|
|
@ -49,10 +49,7 @@ Zotero.Sync.Data.Engine = function (options) {
|
|||
this.apiClient = options.apiClient;
|
||||
this.libraryID = options.libraryID;
|
||||
this.library = Zotero.Libraries.get(options.libraryID);
|
||||
// TODO: Remove
|
||||
this.libraryName = Zotero.Libraries.getName(options.libraryID);
|
||||
this.libraryType = Zotero.Libraries.getType(options.libraryID);
|
||||
switch (this.libraryType) {
|
||||
switch (this.library.libraryType) {
|
||||
case 'user':
|
||||
case 'publications':
|
||||
this.libraryTypeID = Zotero.Users.getCurrentUserID();
|
||||
|
@ -92,10 +89,10 @@ Zotero.Sync.Data.Engine.prototype.UPLOAD_RESULT_LIBRARY_CONFLICT = 3;
|
|||
Zotero.Sync.Data.Engine.prototype.UPLOAD_RESULT_OBJECT_CONFLICT = 4;
|
||||
|
||||
Zotero.Sync.Data.Engine.prototype.start = Zotero.Promise.coroutine(function* () {
|
||||
Zotero.debug("Starting data sync for " + this.libraryName);
|
||||
Zotero.debug("Starting data sync for " + this.library.name);
|
||||
|
||||
// TODO: Handle new/changed user when setting key
|
||||
if (this.libraryType == 'user' && !this.libraryTypeID) {
|
||||
if (this.library.libraryType == 'user' && !this.libraryTypeID) {
|
||||
let info = yield this.apiClient.getKeyInfo();
|
||||
Zotero.debug("Got userID " + info.userID + " for API key");
|
||||
this.libraryTypeID = info.userID;
|
||||
|
@ -140,9 +137,9 @@ Zotero.Sync.Data.Engine.prototype.start = Zotero.Promise.coroutine(function* ()
|
|||
throw new Error("Skipping automatic client reset due to debug pref");
|
||||
}
|
||||
if (autoReset) {
|
||||
throw new Error(this.libraryName + " has already been auto-reset");
|
||||
throw new Error(this.library.name + " has already been auto-reset");
|
||||
}
|
||||
Zotero.logError("Object in " + this.libraryName + " is out of date -- resetting library");
|
||||
Zotero.logError("Object in " + this.library.name + " is out of date -- resetting library");
|
||||
autoReset = true;
|
||||
yield this._fullSync();
|
||||
break;
|
||||
|
@ -168,7 +165,7 @@ Zotero.Sync.Data.Engine.prototype.start = Zotero.Promise.coroutine(function* ()
|
|||
else {
|
||||
let keepGoing = yield gen.next();
|
||||
if (!keepGoing) {
|
||||
throw new Error("Could not sync " + this.libraryName + " -- too many retries");
|
||||
throw new Error("Could not sync " + this.library.name + " -- too many retries");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -179,7 +176,7 @@ Zotero.Sync.Data.Engine.prototype.start = Zotero.Promise.coroutine(function* ()
|
|||
|
||||
yield Zotero.Libraries.updateLastSyncTime(this.libraryID);
|
||||
|
||||
Zotero.debug("Done syncing " + this.libraryName);
|
||||
Zotero.debug("Done syncing " + this.library.name);
|
||||
});
|
||||
|
||||
|
||||
|
@ -231,9 +228,9 @@ Zotero.Sync.Data.Engine.prototype._startDownload = Zotero.Promise.coroutine(func
|
|||
let objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(objectType);
|
||||
|
||||
// Get versions of all objects updated remotely since the current local library version
|
||||
Zotero.debug("Checking for updated " + objectTypePlural + " in " + this.libraryName);
|
||||
Zotero.debug("Checking for updated " + objectTypePlural + " in " + this.library.name);
|
||||
let results = yield this.apiClient.getVersions(
|
||||
this.libraryType,
|
||||
this.library.libraryType,
|
||||
this.libraryTypeID,
|
||||
objectType,
|
||||
libraryVersion ? { since: libraryVersion } : undefined
|
||||
|
@ -250,7 +247,7 @@ Zotero.Sync.Data.Engine.prototype._startDownload = Zotero.Promise.coroutine(func
|
|||
Zotero.logError("Library version changed since last download -- restarting sync");
|
||||
let keepGoing = yield gen.next();
|
||||
if (!keepGoing) {
|
||||
throw new Error("Could not update " + this.libraryName + " -- library in use");
|
||||
throw new Error("Could not update " + this.library.name + " -- library in use");
|
||||
}
|
||||
continue loop;
|
||||
}
|
||||
|
@ -295,7 +292,7 @@ Zotero.Sync.Data.Engine.prototype._startDownload = Zotero.Promise.coroutine(func
|
|||
// Get deleted objects
|
||||
//
|
||||
results = yield this.apiClient.getDeleted(
|
||||
this.libraryType,
|
||||
this.library.libraryType,
|
||||
this.libraryTypeID,
|
||||
libraryVersion
|
||||
);
|
||||
|
@ -307,7 +304,7 @@ Zotero.Sync.Data.Engine.prototype._startDownload = Zotero.Promise.coroutine(func
|
|||
Zotero.logError("Library version changed since last download -- restarting sync");
|
||||
let keepGoing = yield gen.next();
|
||||
if (!keepGoing) {
|
||||
throw new Error("Could not update " + this.libraryName + " -- library in use");
|
||||
throw new Error("Could not update " + this.library.name + " -- library in use");
|
||||
}
|
||||
continue loop;
|
||||
}
|
||||
|
@ -440,7 +437,7 @@ Zotero.Sync.Data.Engine.prototype._startDownload = Zotero.Promise.coroutine(func
|
|||
*/
|
||||
Zotero.Sync.Data.Engine.prototype._downloadSettings = Zotero.Promise.coroutine(function* (libraryVersion) {
|
||||
let results = yield this.apiClient.getSettings(
|
||||
this.libraryType,
|
||||
this.library.libraryType,
|
||||
this.libraryTypeID,
|
||||
libraryVersion
|
||||
);
|
||||
|
@ -489,13 +486,13 @@ Zotero.Sync.Data.Engine.prototype._downloadObjects = Zotero.Promise.coroutine(fu
|
|||
+ (keys.length == 1
|
||||
? "1 " + objectType
|
||||
: Zotero.Utilities.numberFormat(keys.length, 0) + " " + objectTypePlural)
|
||||
+ " in " + this.libraryName
|
||||
+ " in " + this.library.name
|
||||
);
|
||||
|
||||
// Process batches as soon as they're available
|
||||
yield Zotero.Promise.map(
|
||||
this.apiClient.downloadObjects(
|
||||
this.libraryType,
|
||||
this.library.libraryType,
|
||||
this.libraryTypeID,
|
||||
objectType,
|
||||
keys
|
||||
|
@ -583,7 +580,7 @@ Zotero.Sync.Data.Engine.prototype._startUpload = Zotero.Promise.coroutine(functi
|
|||
objectIDs[objectType] = ids;
|
||||
}
|
||||
else {
|
||||
Zotero.debug("No " + objectTypePlural + " to upload in " + this.libraryName);
|
||||
Zotero.debug("No " + objectTypePlural + " to upload in " + this.library.name);
|
||||
}
|
||||
|
||||
// Deleted objects
|
||||
|
@ -591,11 +588,11 @@ Zotero.Sync.Data.Engine.prototype._startUpload = Zotero.Promise.coroutine(functi
|
|||
if (keys.length) {
|
||||
Zotero.debug(`${keys.length} ${objectType} deletion`
|
||||
+ (keys.length == 1 ? '' : 's')
|
||||
+ ` to upload in ${this.libraryName}`);
|
||||
+ ` to upload in ${this.library.name}`);
|
||||
objectDeletions[objectType] = keys;
|
||||
}
|
||||
else {
|
||||
Zotero.debug(`No ${objectType} deletions to upload in ${this.libraryName}`);
|
||||
Zotero.debug(`No ${objectType} deletions to upload in ${this.library.name}`);
|
||||
}
|
||||
|
||||
if (ids.length || keys.length) {
|
||||
|
@ -672,7 +669,7 @@ Zotero.Sync.Data.Engine.prototype._uploadObjects = Zotero.Promise.coroutine(func
|
|||
let numSuccessful = 0;
|
||||
try {
|
||||
let json = yield this.apiClient.uploadObjects(
|
||||
this.libraryType,
|
||||
this.library.libraryType,
|
||||
this.libraryTypeID,
|
||||
"POST",
|
||||
libraryVersion,
|
||||
|
@ -821,7 +818,7 @@ Zotero.Sync.Data.Engine.prototype._uploadDeletions = Zotero.Promise.coroutine(fu
|
|||
try {
|
||||
let batch = keys.slice(0, this.uploadDeletionBatchSize);
|
||||
libraryVersion = yield this.apiClient.uploadDeletions(
|
||||
this.libraryType,
|
||||
this.library.libraryType,
|
||||
this.libraryTypeID,
|
||||
libraryVersion,
|
||||
objectType,
|
||||
|
@ -870,7 +867,7 @@ Zotero.Sync.Data.Engine.prototype._uploadDeletions = Zotero.Promise.coroutine(fu
|
|||
throw e;
|
||||
}
|
||||
}
|
||||
Zotero.debug(`Done uploading ${objectType} deletions in ${this.libraryName}`);
|
||||
Zotero.debug(`Done uploading ${objectType} deletions in ${this.library.name}`);
|
||||
|
||||
return libraryVersion;
|
||||
});
|
||||
|
@ -959,18 +956,18 @@ Zotero.Sync.Data.Engine.prototype._upgradeCheck = Zotero.Promise.coroutine(funct
|
|||
|
||||
let objectTypePlural = Zotero.DataObjectUtilities.getObjectTypePlural(objectType);
|
||||
// TODO: localize
|
||||
this.setStatus("Updating " + objectTypePlural + " in " + this.libraryName);
|
||||
this.setStatus("Updating " + objectTypePlural + " in " + this.library.name);
|
||||
|
||||
// Get versions from API for all objects
|
||||
let allResults = yield this.apiClient.getVersions(
|
||||
this.libraryType,
|
||||
this.library.libraryType,
|
||||
this.libraryTypeID,
|
||||
objectType
|
||||
);
|
||||
|
||||
// Get versions from API for objects modified remotely since the last classic sync time
|
||||
let sinceResults = yield this.apiClient.getVersions(
|
||||
this.libraryType,
|
||||
this.library.libraryType,
|
||||
this.libraryTypeID,
|
||||
objectType,
|
||||
{
|
||||
|
@ -994,7 +991,7 @@ Zotero.Sync.Data.Engine.prototype._upgradeCheck = Zotero.Promise.coroutine(funct
|
|||
+ lastLibraryVersion + ") -- waiting");
|
||||
let keepGoing = yield gen.next();
|
||||
if (!keepGoing) {
|
||||
throw new Error("Could not update " + this.libraryName + " -- library in use");
|
||||
throw new Error("Could not update " + this.library.name + " -- library in use");
|
||||
}
|
||||
continue loop;
|
||||
}
|
||||
|
@ -1023,7 +1020,7 @@ Zotero.Sync.Data.Engine.prototype._upgradeCheck = Zotero.Promise.coroutine(funct
|
|||
let objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(objectType);
|
||||
|
||||
// TODO: localize
|
||||
this.setStatus("Updating " + objectTypePlural + " in " + this.libraryName);
|
||||
this.setStatus("Updating " + objectTypePlural + " in " + this.library.name);
|
||||
|
||||
// Group objects with the same version together and update in batches
|
||||
let versionObjects = {};
|
||||
|
@ -1054,7 +1051,7 @@ Zotero.Sync.Data.Engine.prototype._upgradeCheck = Zotero.Promise.coroutine(funct
|
|||
}
|
||||
}.bind(this));
|
||||
|
||||
Zotero.debug("Done upgrading " + this.libraryName);
|
||||
Zotero.debug("Done upgrading " + this.library.name);
|
||||
|
||||
return versionResults;
|
||||
});
|
||||
|
@ -1074,7 +1071,7 @@ Zotero.Sync.Data.Engine.prototype._upgradeCheck = Zotero.Promise.coroutine(funct
|
|||
* @return {Promise<Integer>} - Promise for the library version after syncing
|
||||
*/
|
||||
Zotero.Sync.Data.Engine.prototype._fullSync = Zotero.Promise.coroutine(function* (versionResults) {
|
||||
Zotero.debug("Performing a full sync of " + this.libraryName);
|
||||
Zotero.debug("Performing a full sync of " + this.library.name);
|
||||
|
||||
var gen;
|
||||
var lastLibraryVersion;
|
||||
|
@ -1093,7 +1090,7 @@ Zotero.Sync.Data.Engine.prototype._fullSync = Zotero.Promise.coroutine(function*
|
|||
let ObjectType = Zotero.Utilities.capitalize(objectType);
|
||||
|
||||
// TODO: localize
|
||||
this.setStatus("Updating " + objectTypePlural + " in " + this.libraryName);
|
||||
this.setStatus("Updating " + objectTypePlural + " in " + this.library.name);
|
||||
|
||||
// Start processing cached objects while waiting for API
|
||||
this._processCache(objectType);
|
||||
|
@ -1106,7 +1103,7 @@ Zotero.Sync.Data.Engine.prototype._fullSync = Zotero.Promise.coroutine(function*
|
|||
// If not available, get from API
|
||||
else {
|
||||
results = yield this.apiClient.getVersions(
|
||||
this.libraryType,
|
||||
this.library.libraryType,
|
||||
this.libraryTypeID,
|
||||
objectType
|
||||
);
|
||||
|
@ -1123,7 +1120,7 @@ Zotero.Sync.Data.Engine.prototype._fullSync = Zotero.Promise.coroutine(function*
|
|||
}
|
||||
let keepGoing = yield gen.next();
|
||||
if (!keepGoing) {
|
||||
throw new Error("Could not update " + this.libraryName + " -- library in use");
|
||||
throw new Error("Could not update " + this.library.name + " -- library in use");
|
||||
}
|
||||
continue loop;
|
||||
}
|
||||
|
@ -1175,7 +1172,7 @@ Zotero.Sync.Data.Engine.prototype._fullSync = Zotero.Promise.coroutine(function*
|
|||
}
|
||||
|
||||
if (toDownload.length) {
|
||||
Zotero.debug("Downloading missing/outdated " + objectTypePlural + " in " + this.libraryName);
|
||||
Zotero.debug("Downloading missing/outdated " + objectTypePlural + " in " + this.library.name);
|
||||
yield this._downloadObjects(objectType, toDownload);
|
||||
}
|
||||
|
||||
|
@ -1189,7 +1186,7 @@ Zotero.Sync.Data.Engine.prototype._fullSync = Zotero.Promise.coroutine(function*
|
|||
// Check remotely deleted objects
|
||||
if (!remoteDeleted) {
|
||||
let results = yield this.apiClient.getDeleted(
|
||||
this.libraryType, this.libraryTypeID
|
||||
this.library.libraryType, this.libraryTypeID
|
||||
);
|
||||
remoteDeleted = results.deleted;
|
||||
}
|
||||
|
@ -1234,7 +1231,7 @@ Zotero.Sync.Data.Engine.prototype._fullSync = Zotero.Promise.coroutine(function*
|
|||
|
||||
yield Zotero.Libraries.setVersion(this.libraryID, lastLibraryVersion);
|
||||
|
||||
Zotero.debug("Done with full sync for " + this.libraryName);
|
||||
Zotero.debug("Done with full sync for " + this.library.name);
|
||||
|
||||
return lastLibraryVersion;
|
||||
});
|
||||
|
|
|
@ -243,7 +243,7 @@ Zotero.Sync.Runner_Module = function (options = {}) {
|
|||
else {
|
||||
// Check access to specified libraries
|
||||
for (let libraryID of libraries) {
|
||||
let type = Zotero.Libraries.getType(libraryID);
|
||||
let type = Zotero.Libraries.get(libraryID).libraryType;
|
||||
if (type == 'user' || type == 'publications') {
|
||||
if (!access.user || !access.user.library) {
|
||||
// TODO: Alert
|
||||
|
@ -306,7 +306,7 @@ Zotero.Sync.Runner_Module = function (options = {}) {
|
|||
remotelyMissingGroups = Zotero.Utilities.arrayDiff(
|
||||
syncAllLibraries
|
||||
? Zotero.Groups.getAll().map(g => g.id)
|
||||
: libraries.filter(id => Zotero.Libraries.getType(id) == 'group')
|
||||
: libraries.filter(id => Zotero.Libraries.get(id).libraryType == 'group')
|
||||
.map(id => Zotero.Groups.getGroupIDFromLibraryID(id)),
|
||||
remoteGroupIDs
|
||||
).map(id => Zotero.Groups.get(id));
|
||||
|
|
|
@ -85,7 +85,7 @@ Zotero.URI = new function () {
|
|||
* Get path portion of library URI (e.g., users/6 or groups/1)
|
||||
*/
|
||||
this.getLibraryPath = function (libraryID) {
|
||||
var libraryType = Zotero.Libraries.getType(libraryID);
|
||||
var libraryType = Zotero.Libraries.get(libraryID).libraryType;
|
||||
|
||||
switch (libraryType) {
|
||||
case 'user':
|
||||
|
|
|
@ -1878,7 +1878,7 @@ var ZoteroPane = new function()
|
|||
// Promises don't work in the modal dialog, so get the group name here, if
|
||||
// applicable, and pass it in. We only need the group that this search belongs
|
||||
// to, if any, since the library drop-down is disabled for saved searches.
|
||||
if (Zotero.Libraries.getType(s.libraryID) == 'group') {
|
||||
if (Zotero.Libraries.get(s.libraryID).libraryType == 'group') {
|
||||
groups.push(yield Zotero.Groups.getByLibraryID(s.libraryID));
|
||||
}
|
||||
var io = {
|
||||
|
|
Loading…
Reference in a new issue