diff --git a/frontend/src/ketr-photos/ketr-photos.html b/frontend/src/ketr-photos/ketr-photos.html index 28e1793..83f2a44 100755 --- a/frontend/src/ketr-photos/ketr-photos.html +++ b/frontend/src/ketr-photos/ketr-photos.html @@ -734,9 +734,17 @@ query += key + "=" + encodeURIComponent(params[key]); } + var path = this.path || ""; console.log("Requesting " + this.limit + " photos."); - window.fetch("api/v1/photos" + (this.path || "") + query, function(error, xhr) { + window.fetch("api/v1/photos" + path + query, function(path, error, xhr) { this.loading = false; + + if (path != (this.path || "")) { + console.log("Skipping results for old query. Triggering re-fetch of photos for new path."); + this._loadPhotos(); + return; + } + if (error) { console.error(JSON.stringify(error, null, 2)); return; @@ -770,7 +778,7 @@ this._loadPhotos(cursor.taken.toString().replace(/T.*/, "") + "_" + cursor.id, true, this.limit * 2); } - }.bind(this)); + }.bind(this, path)); }, _loadAlbums: function() { @@ -779,8 +787,15 @@ } this.loadingAlbums = true; - window.fetch("api/v1/albums" + (this.path || ""), function(error, xhr) { + var path = this.path || ""; + window.fetch("api/v1/albums" + path, function(path, error, xhr) { this.loadingAlbums = false; + if (path != (this.path || "")) { + console.log("Skipping results for old query. Triggering re-fetch of albums for new path."); + this._loadAlbums(); + return; + } + if (error) { console.log("Error loading album: " + (this.path || "")); console.error(JSON.stringify(error, null, 2)); @@ -800,7 +815,7 @@ } this.albums = results; - }.bind(this)); + }.bind(this, path)); }, onResize: function(event) {