diff --git a/frontend/src/ketr-photos/ketr-photos.html b/frontend/src/ketr-photos/ketr-photos.html
index cab5b80..0af12c9 100755
--- a/frontend/src/ketr-photos/ketr-photos.html
+++ b/frontend/src/ketr-photos/ketr-photos.html
@@ -182,6 +182,7 @@
text-overflow: ellipsis;
padding: 0.5em 0;
font-weight: bold;
+ transition: opacity 0.25s ease-in-out;
}
.date-line .album-line {
@@ -909,7 +910,9 @@
return;
}
}
- this.thumbnails[index].visible = false;
+ if (this.thumbnails[index]) {
+ this.thumbnails[index].visible = false;
+ }
}.bind(this));
/* Randomly index the visible array, keeping the center
@@ -1054,6 +1057,7 @@
console.log("Total pending: " + this.pendingPhotos.length);
},
+ /* Asynchronously load items into the DOM */
processItems: function() {
if (this.processing) {
console.log("processItems while processing");
@@ -1236,7 +1240,6 @@
},
_imageAction: function(event) {
- console.log(event.detail);
switch (event.detail) {
case "delete": /* Delete image */
var thumbnail = event.currentTarget;
@@ -1244,15 +1247,46 @@
thumbnail.style.pointerEvents = "none";
this.async(function(thumbnail) {
- thumbnail.parentElement.removeChild(thumbnail);
+ var parent = thumbnail.parentElement;
+
for (var i = 0; i < this.thumbnails.length; i++) {
if (this.thumbnails[i] == thumbnail) {
- console.log("Found thumbnail");
+ console.log("Found thumbnail", this.thumbnails.length);
+ if (thumbnail.visible) {
+ console.log("Removing from visible list");
+ thumbnail.visible = false;
+ var j = this.visibleThumbs.indexOf(i);
+ if (j != -1) {
+ console.log("Removing visible thumb", this.visibleThumbs.length);
+ this.visibleThumbs.splice(j, 1);
+ }
+ }
this.thumbnails.splice(i, 1);
this.notifyPath("thumbnails.length");
break;
}
}
+
+ Polymer.dom(parent).removeChild(thumbnail);
+
+ if (parent.querySelectorAll("photo-thumbnail").length == 0) {
+ /* There are no more thumbnails, so look up the document ancestors
+ * until we find the element with the date-line class, and then
+ * remove it from it's parent */
+ while (parent && !parent.classList.contains("date-line")) {
+ parent = parent.parentElement;
+ }
+ if (!parent) {
+ return;
+ }
+ parent.style.opacity = 0;
+ this.async(function(parent) {
+ Polymer.dom(this.$.thumbnails).removeChild(parent);
+ this.triggerVisibilityChecks();
+ }.bind(this, parent), 250);
+ } else {
+ this.triggerVisibilityChecks();
+ }
}.bind(this, thumbnail), 250);
break;
case "text-format": /* Rename this image */
diff --git a/server/app.js b/server/app.js
index 1c91650..1e22f51 100755
--- a/server/app.js
+++ b/server/app.js
@@ -62,6 +62,7 @@ app.use(bodyParser.urlencoded({
/* Any path starting with the following won't be logged via morgan */
const logSkipPaths = new RegExp("^" + basePath + "(" + [
+ ".*\/thumbs\/",
"bower_components",
].join(")|(") + ")");
app.use(morgan('common', {
diff --git a/server/routes/photos.js b/server/routes/photos.js
index e44a581..ef8f5ef 100755
--- a/server/routes/photos.js
+++ b/server/routes/photos.js
@@ -159,17 +159,19 @@ router.get("/*", function(req, res/*, next*/) {
if (id == -1) {
index = "";
} else {
- index = "AND ((strftime('%m-%d',taken)=strftime('%m-%d',:cursor) AND photos.id<"+id+ ") OR DATE(taken)
limit; /* We queried one extra item to see if there are more than LIMIT available */
+ let last;
if (more) {
photos.splice(limit);
+ last = photos[photos.length - 1];
}
let results = {
- items: photos
+ items: photos.sort(function(a, b) {
+ return new Date(b.taken) - new Date(a.taken);
+ })
};
+
if (more) {
+ results.cursor = new Date(last.taken).toISOString().replace(/T.*/, "") + "_" + last.id;
results.more = true;
}
return res.status(200).json(results);