change item URI when a user begins synching for the first time
This commit is contained in:
parent
05a9932846
commit
dec3ed743c
|
@ -990,7 +990,9 @@ Zotero.Integration.Session.prototype.completeCitation = function(object) {
|
||||||
// get Zotero item (dealing with reselected items along the way)
|
// get Zotero item (dealing with reselected items along the way)
|
||||||
var zoteroItem = false;
|
var zoteroItem = false;
|
||||||
if(citationItem.uri) {
|
if(citationItem.uri) {
|
||||||
zoteroItem = this.uriMap.getZoteroItemForURIs(citationItem.uri);
|
var needUpdate = false;
|
||||||
|
[zoteroItem, needUpdate] = this.uriMap.getZoteroItemForURIs(citationItem.uri);
|
||||||
|
if(needUpdate) this.updateItemIDs[zoteroItem.id] = true;
|
||||||
} else {
|
} else {
|
||||||
if(citationItem.key) {
|
if(citationItem.key) {
|
||||||
zoteroItem = Zotero.Items.getByKey(citationItem.key);
|
zoteroItem = Zotero.Items.getByKey(citationItem.key);
|
||||||
|
@ -1179,13 +1181,15 @@ Zotero.Integration.Session.prototype.editCitation = function(index, citation) {
|
||||||
|
|
||||||
// if there's already a citation, make sure we have item IDs in addition to keys
|
// if there's already a citation, make sure we have item IDs in addition to keys
|
||||||
if(citation) {
|
if(citation) {
|
||||||
|
var zoteroItem;
|
||||||
for each(var citationItem in citation.citationItems) {
|
for each(var citationItem in citation.citationItems) {
|
||||||
var item = false;
|
var item = false;
|
||||||
if(!citationItem.itemID) {
|
if(!citationItem.itemID) {
|
||||||
|
zoteroItem = false;
|
||||||
if(citationItem.uri) {
|
if(citationItem.uri) {
|
||||||
var zoteroItem = this.uriMap.getZoteroItemForURIs(citationItem.uri);
|
[zoteroItem, ] = this.uriMap.getZoteroItemForURIs(citationItem.uri);
|
||||||
} else if(citationItem.key) {
|
} else if(citationItem.key) {
|
||||||
var zoteroItem = Zotero.Items.getByKey(citationItem.key);
|
zoteroItem = Zotero.Items.getByKey(citationItem.key);
|
||||||
}
|
}
|
||||||
if(zoteroItem) citationItem.itemID = zoteroItem.id;
|
if(zoteroItem) citationItem.itemID = zoteroItem.id;
|
||||||
}
|
}
|
||||||
|
@ -1510,9 +1514,11 @@ Zotero.Integration.Session.prototype.loadBibliographyData = function(json) {
|
||||||
if(documentData.uncited) {
|
if(documentData.uncited) {
|
||||||
if(documentData.uncited[0]) {
|
if(documentData.uncited[0]) {
|
||||||
// new style array of arrays with URIs
|
// new style array of arrays with URIs
|
||||||
|
var zoteroItem, needUpdate;
|
||||||
for each(var uris in documentData.uncited) {
|
for each(var uris in documentData.uncited) {
|
||||||
var zoteroItem = this.uriMap.getZoteroItemForURIs(uris);
|
[zoteroItem, needUpdate] = this.uriMap.getZoteroItemForURIs(uris);
|
||||||
if(zoteroItem) this.uncitedItems[zoteroItem.id] = true;
|
if(zoteroItem) this.uncitedItems[zoteroItem.id] = true;
|
||||||
|
if(needUpdate) this.bibliographyDataHasChanged = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(var itemID in documentData.uncited) {
|
for(var itemID in documentData.uncited) {
|
||||||
|
@ -1534,9 +1540,11 @@ Zotero.Integration.Session.prototype.loadBibliographyData = function(json) {
|
||||||
if(documentData.custom) {
|
if(documentData.custom) {
|
||||||
if(documentData.custom[0]) {
|
if(documentData.custom[0]) {
|
||||||
// new style array of arrays with URIs
|
// new style array of arrays with URIs
|
||||||
|
var zoteroItem, needUpdate;
|
||||||
for each(var custom in documentData.custom) {
|
for each(var custom in documentData.custom) {
|
||||||
var zoteroItem = this.uriMap.getZoteroItemForURIs(custom[0]);
|
[zoteroItem, needUpdate] = this.uriMap.getZoteroItemForURIs(custom[0]);
|
||||||
if(!zoteroItem) continue;
|
if(!zoteroItem) continue;
|
||||||
|
if(needUpdate) this.bibliographyDataHasChanged = true;
|
||||||
|
|
||||||
var item = this.itemSet.getItemsByIds([zoteroItem.id])[0];
|
var item = this.itemSet.getItemsByIds([zoteroItem.id])[0];
|
||||||
if(!item) continue;
|
if(!item) continue;
|
||||||
|
@ -1710,12 +1718,25 @@ Zotero.Integration.URIMap.prototype.getURIsForItemID = function(id) {
|
||||||
*/
|
*/
|
||||||
Zotero.Integration.URIMap.prototype.getZoteroItemForURIs = function(uris) {
|
Zotero.Integration.URIMap.prototype.getZoteroItemForURIs = function(uris) {
|
||||||
var zoteroItem = false;
|
var zoteroItem = false;
|
||||||
for each(var uri in uris) {
|
var needUpdate = false;
|
||||||
|
|
||||||
|
for(var i in uris) {
|
||||||
try {
|
try {
|
||||||
zoteroItem = Zotero.URI.getURIItem(uri);
|
zoteroItem = Zotero.URI.getURIItem(uris[i]);
|
||||||
if(zoteroItem) break;
|
if(zoteroItem) break;
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
}
|
}
|
||||||
if(zoteroItem) this.itemIDURIs[zoteroItem.id] = uris;
|
|
||||||
return zoteroItem;
|
if(zoteroItem) {
|
||||||
|
// make sure URI is up to date (in case user just began synching)
|
||||||
|
var newURI = Zotero.URI.getItemURI(zoteroItem);
|
||||||
|
if(newURI != uris[i]) {
|
||||||
|
uris[i] = newURI;
|
||||||
|
needUpdate = true;
|
||||||
|
}
|
||||||
|
// cache uris
|
||||||
|
this.itemIDURIs[zoteroItem.id] = uris;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [zoteroItem, needUpdate];
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user