From 0096e2769f69bda37025932409e7a3943dde79dc Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Sun, 6 Mar 2016 18:32:20 +0100 Subject: [PATCH] Wait for content to be loaded before showing photo --- src/scripts/photo.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/scripts/photo.js b/src/scripts/photo.js index 5c54fb9..a758948 100644 --- a/src/scripts/photo.js +++ b/src/scripts/photo.js @@ -24,6 +24,21 @@ photo.getID = function() { photo.load = function(photoID, albumID) { + const checkContent = function() { + if (album.json!=null) photo.load(photoID, albumID) + else setTimeout(checkContent, 100) + } + + const checkPasswd = function() { + if (password.value!=='') photo.load(photoID, albumID) + else setTimeout(checkPasswd, 200) + } + + if (album.json==null) { + checkContent() + return false + } + let params = { photoID, albumID, @@ -32,11 +47,6 @@ photo.load = function(photoID, albumID) { api.post('Photo::get', params, function(data) { - const checkPasswd = function() { - if (password.value!=='') photo.load(photoID, albumID) - else setTimeout(checkPasswd, 250) - } - if (data==='Warning: Photo private!') { lychee.content.show() lychee.goto()