Avoid repeated file existence checks for some files in getImageSrc()

This commit is contained in:
Dan Stillman 2016-02-06 03:25:28 -05:00
parent 1855b5e1f9
commit 47e9f82927
2 changed files with 9 additions and 6 deletions

View File

@ -2081,6 +2081,7 @@ Zotero.Item.prototype.getFilePathAsync = Zotero.Promise.coroutine(function* () {
// Ignore .zotero* files that were relinked before we started blocking them
if (path.startsWith(".zotero")) {
Zotero.debug("Ignoring attachment file " + path, 2);
this._updateAttachmentStates(false);
return false;
}
@ -2111,6 +2112,8 @@ Zotero.Item.prototype.getFilePathAsync = Zotero.Promise.coroutine(function* () {
this._updateAttachmentStates(false);
return false;
}
this._updateAttachmentStates(true);
return path;
}

View File

@ -1037,8 +1037,6 @@ Zotero.ItemTreeView.prototype.getCellText = function (row, column)
Zotero.ItemTreeView.prototype.getImageSrc = function(row, col)
{
var self = this;
if(col.id == 'zotero-items-column-title')
{
// Get item type icon and tag swatches
@ -1086,8 +1084,8 @@ Zotero.ItemTreeView.prototype.getImageSrc = function(row, col)
item.getBestAttachmentState()
// Refresh cell when promise is fulfilled
.then(function (state) {
self._treebox.invalidateCell(row, col);
})
this._treebox.invalidateCell(row, col);
}.bind(this))
.done();
}
}
@ -1103,10 +1101,12 @@ Zotero.ItemTreeView.prototype.getImageSrc = function(row, col)
item.fileExists()
// Refresh cell when promise is fulfilled
.then(function (exists) {
self._treebox.invalidateCell(row, col);
});
this._treebox.invalidateCell(row, col);
}.bind(this));
}
}
return "";
}
Zotero.ItemTreeView.prototype.isContainer = function(row)