diff --git a/frontend/static/js/random.js b/frontend/static/js/random.js index baa6910..6fe319f 100644 --- a/frontend/static/js/random.js +++ b/frontend/static/js/random.js @@ -99,21 +99,6 @@ function ShowVideo(data) { localStorage.setItem('lastSeen', data.video.id) } -if (localStorage.getItem('lastSeen')) { - fetch(`/api/videos/${localStorage.getItem('lastSeen')}`) - .then(response => response.json()) - .then(data => ShowVideo(data)) -} else { - fetch( - `/api/videos/random`, - { - headers: {"visitor": localStorage.getItem('visitor')} - } - ) - .then(response => response.json()) - .then(data => ShowVideo(data)) -} - document.getElementById("random").onclick = function() { let mainButtonMessageDelay = 800 this.style.filter = "grayscale(100%)"; @@ -168,3 +153,18 @@ document.getElementById("random").onclick = function() { ) }) } + +if (localStorage.getItem('lastSeen')) { + fetch(`/api/videos/${localStorage.getItem('lastSeen')}`) + .then(response => response.json()) + .then(data => ShowVideo(data)) +} else { + fetch( + `/api/videos/random`, + { + headers: {"visitor": localStorage.getItem('visitor')} + } + ) + .then(response => response.json()) + .then(data => ShowVideo(data)) +} \ No newline at end of file