fix: front-end not save token
fix: sometimes not auto stream next video
This commit is contained in:
@@ -378,7 +378,7 @@
|
||||
|
||||
ws.onopen = function () {
|
||||
console.log("Connected to WebSocket");
|
||||
setStoredToken(document.getElementById("token-input").value);
|
||||
setStoredToken(token);
|
||||
document.getElementById("token-screen").style.display = "none";
|
||||
document.querySelector(".container-fluid").style.display = "flex";
|
||||
document.getElementById("status").textContent =
|
||||
@@ -404,7 +404,6 @@
|
||||
};
|
||||
|
||||
ws.onerror = function () {
|
||||
localStorage.removeItem("streaming_token");
|
||||
document.getElementById("token-error").style.display = "block";
|
||||
};
|
||||
|
||||
@@ -425,12 +424,20 @@
|
||||
localStorage.setItem("streaming_token", token);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const storedToken = getStoredToken();
|
||||
if (storedToken) {
|
||||
document.getElementById("token-input").value = storedToken;
|
||||
validateToken();
|
||||
}
|
||||
});
|
||||
|
||||
function validateToken() {
|
||||
const tokenInput = document.getElementById("token-input");
|
||||
const token = tokenInput.value || getStoredToken();
|
||||
if (token) {
|
||||
tokenInput.value = token;
|
||||
if (tokenInput.value) {
|
||||
connectWebSocket();
|
||||
} else {
|
||||
document.getElementById("token-error").style.display = "block";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user