diff --git a/Directory.Build.props b/Directory.Build.props index 8881498..2cde674 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 1.0.0.3 - 1.0.0.3 - 1.0.0.3 + 1.0.0.4 + 1.0.0.4 + 1.0.0.4 diff --git a/Jellyfin.Plugin.Request/Web/nav-loader.js b/Jellyfin.Plugin.Request/Web/nav-loader.js index fd1ae2b..039e268 100644 --- a/Jellyfin.Plugin.Request/Web/nav-loader.js +++ b/Jellyfin.Plugin.Request/Web/nav-loader.js @@ -8,6 +8,7 @@ let ensuring = null; let assetsPromise = null; + let guardAttached = false; function ensureStyle() { if (document.getElementById(STYLE_ID)) { @@ -17,7 +18,7 @@ const style = document.createElement("style"); style.id = STYLE_ID; style.textContent = [ - ".jf-request-tab-panel{padding:1rem 1.25rem 2rem;box-sizing:border-box;}", + ".jf-request-tab-panel{padding:1rem 1.25rem 2rem;box-sizing:border-box;min-height:50vh;}", ".jf-request-tab-panel .req-embed{max-width:1400px;margin:0 auto;}", ".jf-request-menu-item{align-items:center;color:inherit;display:flex!important;gap:1rem;min-height:3rem;padding:.75rem 1.25rem;text-decoration:none;cursor:pointer;background:none;border:0;width:100%;text-align:left;font:inherit;}", ".jf-request-menu-item:hover,.jf-request-menu-item:focus{color:#00a4dc;}", @@ -99,8 +100,10 @@ function createTabPanel() { const panel = document.createElement("div"); + // Match SeerrFin: start without .hide; visibility is synced on tab change. panel.className = "tabContent pageTabContent hide jf-request-tab-panel"; panel.setAttribute(TAB_ATTR, "request"); + panel.id = "jellyfinRequestTab"; const mount = document.createElement("div"); mount.className = "sections jf-request-sections"; @@ -110,7 +113,14 @@ } function findNativeButtons(tabsSlider) { - return Array.from(tabsSlider.querySelectorAll(".emby-tab-button")).filter((btn) => !btn.hasAttribute(TAB_ATTR)); + return Array.from(tabsSlider.querySelectorAll(".emby-tab-button")).filter((btn) => { + if (btn.hasAttribute(TAB_ATTR)) { + return false; + } + + const id = btn.id || ""; + return id.indexOf("customTabButton_") !== 0; + }); } function placeInOrder(parent, nodes) { @@ -147,7 +157,6 @@ return; } - // Native home/favorites panels. if (index === 0) { page.querySelector("#homeTab")?.setAttribute("data-index", "0"); } else if (index === 1) { @@ -156,18 +165,100 @@ }); } + function syncPanelVisibility(selectedIndex) { + const page = document.getElementById("indexPage"); + if (!page || isNaN(selectedIndex)) { + return; + } + + page.querySelectorAll(".tabContent[data-index]").forEach((panel) => { + const panelIndex = parseInt(panel.getAttribute("data-index"), 10); + const active = panelIndex === selectedIndex; + panel.classList.toggle("hide", !active); + panel.classList.toggle("is-active", active); + }); + } + async function mountRequestUi(panel) { const mount = panel.querySelector('[data-role="request-mount"]'); if (!mount) { return; } - await loadAssets(); + try { + await loadAssets(); + } catch (error) { + mount.textContent = "Failed to load Request UI."; + console.error("[Jellyfin.Plugin.Request]", error); + return; + } + if (window.JellyfinRequestUI) { window.JellyfinRequestUI.mount(mount, { embed: true }); + } else { + mount.textContent = "Request UI failed to initialize."; } } + function isRequestTabButton(button) { + return !!(button && button.getAttribute(TAB_ATTR) === "request"); + } + + function attachPluginTabGuard(tabsEl) { + if (!tabsEl || guardAttached || tabsEl.dataset.jfRequestTabGuard === "true") { + return; + } + + guardAttached = true; + tabsEl.dataset.jfRequestTabGuard = "true"; + + tabsEl.addEventListener("beforetabchange", (event) => { + if (!isHomeTabContext()) { + return; + } + + const index = parseInt(event.detail && event.detail.selectedTabIndex, 10); + if (isNaN(index)) { + return; + } + + // Jellyfin activates panels by NodeList order; keep data-index panels in sync. + syncPanelVisibility(index); + + const selectedButton = tabsEl.querySelector(`.emby-tab-button[data-index="${index}"]`); + if (isRequestTabButton(selectedButton)) { + const panel = document.querySelector(`.tabContent[${TAB_ATTR}="request"]`); + if (panel) { + mountRequestUi(panel); + } + } + }, true); + + // HomeView only knows Home/Favorites. Stop its handler for our tab so content is not cleared. + tabsEl.addEventListener("tabchange", (event) => { + if (!isHomeTabContext()) { + return; + } + + const index = parseInt(event.detail && event.detail.selectedTabIndex, 10); + if (isNaN(index)) { + return; + } + + const selectedButton = tabsEl.querySelector(`.emby-tab-button[data-index="${index}"]`); + if (!isRequestTabButton(selectedButton)) { + return; + } + + event.stopImmediatePropagation(); + syncPanelVisibility(index); + const panel = document.querySelector(`.tabContent[${TAB_ATTR}="request"]`); + if (panel) { + mountRequestUi(panel); + } + }, true); + } + function activateRequestTab() { if (!isHomeTabContext()) { window.location.hash = "#/home"; @@ -259,6 +350,8 @@ return; } + attachPluginTabGuard(tabsEl); + let button = tabsSlider.querySelector(`[${TAB_ATTR}="request"]`); if (!button) { button = createTabButton(); @@ -290,7 +383,8 @@ } } - await mountRequestUi(panel); + // Preload assets so the first click is instant; do not force-show the panel. + await loadAssets().catch(() => { /* surfaced on mount */ }); })().finally(() => { ensuring = null; }); @@ -306,11 +400,18 @@ } }); window.addEventListener("hashchange", () => ensureRequestTab()); - setInterval(() => ensureRequestTab(), 1500); + setInterval(() => ensureRequestTab(), 2000); const headerTabs = document.querySelector(".headerTabs"); if (headerTabs) { - new MutationObserver(() => ensureRequestTab()).observe(headerTabs, { childList: true, subtree: true }); + let timer = null; + new MutationObserver(() => { + if (timer) { + clearTimeout(timer); + } + + timer = setTimeout(() => ensureRequestTab(), 250); + }).observe(headerTabs, { childList: true, subtree: true }); } } diff --git a/Jellyfin.Plugin.Request/Web/request.css b/Jellyfin.Plugin.Request/Web/request.css index fa867fb..f317a5a 100644 --- a/Jellyfin.Plugin.Request/Web/request.css +++ b/Jellyfin.Plugin.Request/Web/request.css @@ -10,25 +10,26 @@ --req-warn: #f0ad4e; } -* { +.req-root, +.req-root * { box-sizing: border-box; } -html, -body { +body.jellyfin-request-standalone { margin: 0; min-height: 100%; + padding: 1.25rem; background: var(--req-bg); color: var(--req-text); font-family: Inherit, "Segoe UI", Roboto, sans-serif; } -body { - padding: 1.25rem; +.req-root { + color: var(--req-text); + font-family: Inherit, "Segoe UI", Roboto, sans-serif; } .req-embed { - color: inherit; background: transparent; padding: 0; } diff --git a/Jellyfin.Plugin.Request/Web/requestPage.html b/Jellyfin.Plugin.Request/Web/requestPage.html index 5c06198..f34717c 100644 --- a/Jellyfin.Plugin.Request/Web/requestPage.html +++ b/Jellyfin.Plugin.Request/Web/requestPage.html @@ -6,7 +6,7 @@ Request - +
diff --git a/build.yaml b/build.yaml index 0ea23b7..e3b8eb8 100644 --- a/build.yaml +++ b/build.yaml @@ -1,7 +1,7 @@ --- name: "Request" guid: "11c08950-c4bb-484d-89ff-205b3724416b" -version: "1.0.0.3" +version: "1.0.0.4" targetAbi: "10.11.11.0" framework: "net9.0" overview: "Request movies and TV shows from a local admin review queue" diff --git a/manifest.json b/manifest.json index 66f64d7..af93ead 100644 --- a/manifest.json +++ b/manifest.json @@ -9,12 +9,12 @@ "repositoryUrl": "https://git.masengr.com/Michael-A-Sloan/Jellyfin_Request_tvandmovies", "versions": [ { - "version": "1.0.0.3", - "changelog": "Show Request UI under the home top tabs like Home/Favorites instead of navigating away", + "version": "1.0.0.4", + "changelog": "Fix blank Request tab by syncing panel visibility and blocking Jellyfin HomeView tab handlers", "targetAbi": "10.11.11.0", - "sourceUrl": "https://git.masengr.com/Michael-A-Sloan/Jellyfin_Request_tvandmovies/raw/branch/main/release/Jellyfin.Plugin.Request_1.0.0.3.zip", - "checksum": "F11AA68370A2E1B81AC14EB6D1DB123C", - "timestamp": "2026-08-02T21:00:07.1780246Z", + "sourceUrl": "https://git.masengr.com/Michael-A-Sloan/Jellyfin_Request_tvandmovies/raw/branch/main/release/Jellyfin.Plugin.Request_1.0.0.4.zip", + "checksum": "5A31B38274F40F3AF3DE0240D2319C1E", + "timestamp": "2026-08-02T21:03:57.4534409Z", "dependencies": [] } ] diff --git a/release/Jellyfin.Plugin.Request_1.0.0.4.zip b/release/Jellyfin.Plugin.Request_1.0.0.4.zip new file mode 100644 index 0000000..31bbcf1 Binary files /dev/null and b/release/Jellyfin.Plugin.Request_1.0.0.4.zip differ diff --git a/scripts/package-release.ps1 b/scripts/package-release.ps1 index d084c4d..7f32a85 100644 --- a/scripts/package-release.ps1 +++ b/scripts/package-release.ps1 @@ -1,5 +1,5 @@ param( - [string]$Version = "1.0.0.3", + [string]$Version = "1.0.0.4", [string]$TargetAbi = "10.11.11.0", [string]$RepoRawBase = "https://git.masengr.com/Michael-A-Sloan/Jellyfin_Request_tvandmovies/raw/branch/main" ) @@ -17,7 +17,7 @@ $dllPath = Join-Path $root "Jellyfin.Plugin.Request\bin\Release\net9.0\Jellyfin. $zipPath = Join-Path $releaseDir $zipFileName $manifestPath = Join-Path $root "manifest.json" $timestamp = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ") -$changelog = "Show Request UI under the home top tabs like Home/Favorites instead of navigating away" +$changelog = "Fix blank Request tab by syncing panel visibility and blocking Jellyfin HomeView tab handlers" Write-Host "Building plugin..." dotnet build (Join-Path $root "Jellyfin.Plugin.Request.sln") -c Release