Timing problems while deleting assets.
Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
parent
c1e5503c01
commit
4790e8e62d
@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<link rel="import" href="../bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="../bower_components/paper-icon-button/paper-icon-button.html">
|
||||
<link rel="import" href="../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
|
||||
<link rel="import" href="../bower_components/iron-icon/iron-icon.html">
|
||||
<link rel="import" href="../bower_components/iron-icons/iron-icons.html">
|
||||
<link rel="import" href="../bower_components/iron-pages/iron-pages.html">
|
||||
@ -41,10 +42,12 @@
|
||||
}
|
||||
|
||||
#actions {
|
||||
display: flex;
|
||||
padding: 0.5em;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
opacity: 0;
|
||||
font-size: 0.6em;
|
||||
color: #ddd;
|
||||
}
|
||||
|
||||
:host(:hover) #info,
|
||||
@ -54,7 +57,7 @@
|
||||
|
||||
</style>
|
||||
|
||||
<div id="actions" hidden$="[[!actions.length]]" class="horziontal layout center end">
|
||||
<div id="actions" hidden$="[[!actions.length]]" class="flex horziontal layout center end-justified">
|
||||
<template is="dom-repeat" items="[[actions]]">
|
||||
<paper-icon-button on-tap="_fireAction" icon="[[item]]"></paper-icon-button>
|
||||
</template>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
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 */
|
||||
|
@ -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', {
|
||||
|
@ -159,13 +159,15 @@ 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)<DATE(:cursor))";
|
||||
index = "AND ((strftime('%Y-%m-%d',taken)=strftime('%Y-%m-%d',:cursor) AND photos.id<"+id+ ") OR " +
|
||||
"(strftime('%m-%d',taken)=strftime('%m-%d',:cursor) AND strftime('%Y',taken)<strftime('%Y',:cursor)))";
|
||||
}
|
||||
|
||||
let path = decodeURI(req.url).replace(/\?.*$/, "").replace(/^\//, ""),
|
||||
query = "SELECT photos.*,albums.path AS path FROM photos " +
|
||||
"INNER JOIN albums ON (albums.id=photos.albumId AND albums.path LIKE :path) " +
|
||||
"WHERE (photos.duplicate=0 AND photos.deleted=0 AND photos.scanned NOT NULL " + index + ") ORDER BY taken DESC,id DESC LIMIT " + (limit * 2 + 1),
|
||||
"WHERE (photos.duplicate=0 AND photos.deleted=0 AND photos.scanned NOT NULL " + index + ") " +
|
||||
"ORDER BY strftime('%Y-%m-%d',taken) DESC,id DESC LIMIT " + (limit + 1),
|
||||
replacements = {
|
||||
cursor: cursor,
|
||||
path: path + "%"
|
||||
@ -185,26 +187,22 @@ router.get("/*", function(req, res/*, next*/) {
|
||||
}
|
||||
});
|
||||
|
||||
if (cursor) {
|
||||
cursor = moment(cursor);
|
||||
photos = photos.filter(function(photo) {
|
||||
if (!cursor.isSame(photo.taken, "day")) {
|
||||
return true;
|
||||
}
|
||||
return photo.id < id;
|
||||
});
|
||||
}
|
||||
|
||||
let more = photos.length > 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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user