Keep same album on subsequent data load call to /photos

Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
James Ketr 2018-08-30 09:04:19 -07:00
parent a168001830
commit c05f1ab8e5

View File

@ -427,6 +427,11 @@
console.log("Max per day: " + this.cols); console.log("Max per day: " + this.cols);
} }
var albums = this.querySelectorAll(".album-line");
if (albums.length) {
lastPath = albums[albums.length - 1];
}
thisDay = 0; thisDay = 0;
for (var i = 0; i < photos.length; i++) { for (var i = 0; i < photos.length; i++) {
var photo = photos[i], var photo = photos[i],
@ -438,6 +443,26 @@
thumbnail.addEventListener("load-album", this.loadAlbum.bind(this)); thumbnail.addEventListener("load-album", this.loadAlbum.bind(this));
datetime = (photo.taken || photo.modified || photo.added).replace(/T.*$/, ""); datetime = (photo.taken || photo.modified || photo.added).replace(/T.*$/, "");
if (this.order == "by-album") {
if (lastPath != photo.path) {
lastPath = photo.path;
var albumBlock = document.createElement("div");
albumBlock.classList.add("album-line");
albumBlock.classList.add("layout");
albumBlock.classList.add("horizontal");
var trail = this.breadcrumb(lastPath);
trail.forEach(function(crumb) {
var div = document.createElement("div");
div.path = crumb.path;
div.textContent = crumb.name + " /";
div.addEventListener("tap", this.pathTapped.bind(this));
albumBlock.appendChild(div);
}.bind(this));
Polymer.dom(this.$.thumbnails).appendChild(albumBlock);
}
}
if (this.breakOnDayChange) { if (this.breakOnDayChange) {
var dateBlock = this.querySelector("#date-" + datetime); var dateBlock = this.querySelector("#date-" + datetime);
if (!dateBlock) { if (!dateBlock) {
@ -463,25 +488,6 @@
} }
} }
if (this.order == "by-album") {
if (lastPath != photo.path) {
lastPath = photo.path;
var albumBlock = document.createElement("div");
albumBlock.classList.add("album-line");
albumBlock.classList.add("layout");
albumBlock.classList.add("horizontal");
var trail = this.breadcrumb(lastPath);
trail.forEach(function(crumb) {
var div = document.createElement("div");
div.path = crumb.path;
div.textContent = crumb.name + " /";
div.addEventListener("tap", this.pathTapped.bind(this));
albumBlock.appendChild(div);
}.bind(this));
Polymer.dom(this.$.thumbnails).appendChild(albumBlock);
}
}
if (!this.limitPerFolder || thisDay < this.cols) { if (!this.limitPerFolder || thisDay < this.cols) {
Polymer.dom(this.$.thumbnails).appendChild(thumbnail); Polymer.dom(this.$.thumbnails).appendChild(thumbnail);