feat: integrate loading state into player init and remove metadata fetch

This commit is contained in:
2026-07-06 07:09:56 +02:00
parent 7215b1a4ee
commit 413759c454
2 changed files with 71 additions and 61 deletions

View File

@@ -1,31 +0,0 @@
import { state } from "../state";
/** Fetches episode metadata from API and updates episode-card titles. */
export const setupEpisodeMetadata = (): void => {
const { episodeList } = state.elements;
if (!episodeList) {
return;
}
fetch(`/api/watch/episodes/${state.episode.malID}/metadata`)
.then((res) => res.json())
.then((data: Array<{ mal_id: number; title?: string }>) => {
data.forEach((item) => {
const card = episodeList.querySelector(`[data-episode-id="${item.mal_id}"]`);
if (!card) {
return;
}
if (item.title) {
const titleEl = card.querySelector("[data-episode-title]");
if (titleEl) {
titleEl.textContent = item.title;
}
}
});
})
.catch((error) => {
window.showToast?.({ message: "Failed to load episode metadata." });
console.error("failed to load episode metadata:", error);
});
};