From a6f7c4fbecd77fb7b9ab7b569c6fdf6f37c09fe6 Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Wed, 5 Sep 2018 20:35:49 -0700 Subject: [PATCH] Dynamic load of entire site Signed-off-by: James Ketrenos --- frontend/src/ketr-photos/ketr-photos.html | 13 +++++++++++-- server/routes/photos.js | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/frontend/src/ketr-photos/ketr-photos.html b/frontend/src/ketr-photos/ketr-photos.html index f26685a..d1d84cd 100755 --- a/frontend/src/ketr-photos/ketr-photos.html +++ b/frontend/src/ketr-photos/ketr-photos.html @@ -596,6 +596,13 @@ Polymer.dom(thumbnails).appendChild(thumbnail); this.thumbnails.push(thumbnail); + + if (this.next) { + this.async(function() { + var cursor = this.photos[this.photos.length - 1]; + this._loadPhotos(cursor.taken.toString().replace(/T.*/, "") + "_" + cursor.id, -1, true, this.limit * 2); + }, 250); + } } this.triggerVisibilityChecks(); @@ -610,15 +617,17 @@ this._loadPhotos(); }, - _loadPhotos: function(start, dir, append) { + _loadPhotos: function(start, dir, append, limit) { if (this.loading == true) { return; } this.loading = true; + this.limit = limit || 500; + dir = dir || -1; var params = { - limit: Math.ceil(this.clientWidth / 200) * Math.ceil(this.clientHeight / 200), + limit: this.limit, dir: dir }, query = ""; if (start) { diff --git a/server/routes/photos.js b/server/routes/photos.js index 7fbe86b..d19aa45 100755 --- a/server/routes/photos.js +++ b/server/routes/photos.js @@ -55,7 +55,7 @@ router.get("/*", function(req, res/*, next*/) { } } - let query = "SELECT * FROM photos WHERE path LIKE :path " + index + " ORDER BY taken " + order + ",id " + order + " LIMIT 1000";// + " LIMIT " + (limit * 2 + 1); + let query = "SELECT * FROM photos WHERE path LIKE :path " + index + " ORDER BY taken " + order + ",id " + order + " LIMIT " + (limit * 2 + 1); return photoDB.sequelize.query(query, { replacements: { cursor: cursor,