diff --git a/src/scripts/album.js b/src/scripts/album.js index 544eb25..4a2a427 100644 --- a/src/scripts/album.js +++ b/src/scripts/album.js @@ -49,6 +49,12 @@ album.load = function(albumID, refresh = false) { if (data==='Warning: Album private!') { + // if we were in private mode, restart lychee. maybe the cookie has expired + if (!lychee.publicMode) { + lychee.restart() + return false + } + if (document.location.hash.replace('#', '').split('/')[1]!=undefined) { // Display photo only lychee.setMode('view') diff --git a/src/scripts/lychee.js b/src/scripts/lychee.js index 105e5ba..2c4b4e5 100644 --- a/src/scripts/lychee.js +++ b/src/scripts/lychee.js @@ -144,6 +144,12 @@ lychee.logout = function() { } +lychee.restart = function() { + + document.location.href = '' + +} + lychee.goto = function(url = '') { url = '#' + url @@ -418,6 +424,12 @@ lychee.html = function(literalSections, ...substs) { lychee.error = function(errorThrown, params, data) { + // if the requested function was not found, our cookie has probably expired + if (data.startsWith('Error: Function not found!')) { + lychee.restart() + return + } + console.error({ description : errorThrown, params : params, diff --git a/src/scripts/photo.js b/src/scripts/photo.js index 860ad68..dc6bdd7 100644 --- a/src/scripts/photo.js +++ b/src/scripts/photo.js @@ -48,9 +48,17 @@ photo.load = function(photoID, albumID) { api.post('Photo::get', params, function(data) { if (data==='Warning: Photo private!') { + + // if we were in private mode, restart lychee. maybe the cookie has expired + if (!lychee.publicMode) { + lychee.restart() + return false + } + lychee.content.show() lychee.goto() return false + } if (data==='Warning: Wrong password!') {