Fix updating chat on playlist reload for restreamer page

pull/305/head
ElementalAlchemist 2 years ago committed by Mike Lang
parent 4a1880461f
commit 76de577695

@ -55,9 +55,8 @@ window.addEventListener("DOMContentLoaded", async (event) => {
container.appendChild(newField); container.appendChild(newField);
}); });
updateTimeSettings(); await updateTimeSettings();
await getStreamChatLog();
const videoPlayer = document.getElementById("video"); const videoPlayer = document.getElementById("video");
videoPlayer.addEventListener("loadedmetadata", (_event) => initialChatRender()); videoPlayer.addEventListener("loadedmetadata", (_event) => initialChatRender());
videoPlayer.addEventListener("timeupdate", (_event) => updateChatRender()); videoPlayer.addEventListener("timeupdate", (_event) => updateChatRender());
@ -105,7 +104,7 @@ function dateTimeFromTimeString(timeString, timeStringFormat) {
} }
} }
function updateTimeSettings() { async function updateTimeSettings() {
updateStoredTimeSettings(); updateStoredTimeSettings();
if (globalLoadedVideoPlayer) { if (globalLoadedVideoPlayer) {
updateSegmentPlaylist(); updateSegmentPlaylist();
@ -125,6 +124,8 @@ function updateTimeSettings() {
queryParts.push(`end=${wubloaderTimeFromDateTime(endTime)}`); queryParts.push(`end=${wubloaderTimeFromDateTime(endTime)}`);
} }
document.getElementById("stream-time-link").href = `?${queryParts.join("&")}`; document.getElementById("stream-time-link").href = `?${queryParts.join("&")}`;
await getStreamChatLog();
} }
function generateDownloadURL(startTime, endTime, downloadType, allowHoles, quality) { function generateDownloadURL(startTime, endTime, downloadType, allowHoles, quality) {
@ -262,6 +263,10 @@ function updateChatRender() {
if (!globalChatData) { if (!globalChatData) {
return; return;
} }
if (!hasSegmentList()) {
// The update is due to a stream refresh, so we'll wait for the initial render instead
return;
}
const videoPlayer = document.getElementById("video"); const videoPlayer = document.getElementById("video");
const videoTime = videoPlayer.currentTime; const videoTime = videoPlayer.currentTime;

Loading…
Cancel
Save