Skip to content

Commit

Permalink
try speed page loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima committed Nov 3, 2023
1 parent fb5dc92 commit a36b0e6
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions frontend/static/js/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -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%)";
Expand Down Expand Up @@ -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))
}

0 comments on commit a36b0e6

Please sign in to comment.