Lightbox delete should close lightbox

Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
James Ketr 2018-10-17 20:37:40 -07:00
parent 562debdd04
commit 2e98b93078
2 changed files with 30 additions and 18 deletions

View File

@ -179,6 +179,10 @@ Polymer({
}, },
onKeyDown: function(e) { onKeyDown: function(e) {
if (!this.active) {
return;
}
if (e.ctrlKey || e.altKey || e.metaKey || e.shiftKey) { if (e.ctrlKey || e.altKey || e.metaKey || e.shiftKey) {
return; return;
} }
@ -202,6 +206,7 @@ Polymer({
console.log(e.keyCode); console.log(e.keyCode);
break; break;
} }
if (this.hasFocus) { if (this.hasFocus) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@ -237,7 +242,12 @@ Polymer({
}, },
close: function() { close: function() {
if (this.closed) {
return;
}
this.style.opacity = 0; this.style.opacity = 0;
this.async(function() { this.async(function() {
this.setActive(false); this.setActive(false);
this.style.display = 'none'; this.style.display = 'none';

View File

@ -1344,26 +1344,28 @@
} }
window.fetch("api/v1/photos/" + thumbnail.item.id + query, window.fetch("api/v1/photos/" + thumbnail.item.id + query,
this._removeImageAfterFetch.bind(this, thumbnail, function() { this._removeImageAfterFetch.bind(this, thumbnail, function() {
/* In duplicates mode, if an image is deleted it has the same /* If there is a lightbox, close the lightbox */
* effect as renaming it since it removes it from the view */ this.$.lightbox.close();
if (this.mode != "duplicates") { /* In duplicates mode, if an image is deleted it has the same
return; * effect as renaming it since it removes it from the view */
} if (this.mode != "duplicates") {
/* If there is now only one item with this thumbnail's name, return;
* remove it from the view */ }
var orphan = null; /* If there is now only one item with this thumbnail's name,
for (var i = 0; i < this.thumbnails.length; i++) { * remove it from the view */
if (this.thumbnails[i].item.filename == thumbnail.item.filename) { var orphan = null;
if (orphan) { for (var i = 0; i < this.thumbnails.length; i++) {
return; if (this.thumbnails[i].item.filename == thumbnail.item.filename) {
} if (orphan) {
orphan = this.thumbnails[i]; return;
} }
orphan = this.thumbnails[i];
} }
if (orphan) { }
this._removeImageAfterFetch(orphan, null); if (orphan) {
} this._removeImageAfterFetch(orphan, null);
}.bind(this)), {}, "DELETE"); }
}.bind(this)), {}, "DELETE");
}, },
renameAction: function(thumbnail) { renameAction: function(thumbnail) {