refactor: rename player thumbnail module to metadata

This commit is contained in:
2026-06-27 15:34:02 +02:00
parent 0480b70dfc
commit 75520aa1a3
3 changed files with 33 additions and 58 deletions

View File

@@ -0,0 +1,31 @@
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);
});
};