feat(request): custom titles and remount blank request tab
Allow movie/TV requests without a TMDB match via a Custom form, and remount the embedded Request UI when the home tab opens empty. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
2eed62390b
commit
7044023d98
12 files changed
+312
-33
No files matched your search
@@ -182,7 +182,14 @@
|
||||
});
|
||||
}
|
||||
|
||||
async function mountRequestUi(panel) {
|
||||
async function mountRequestUi(panel, forceRemount) {
|
||||
if (!panel) {
|
||||
return;
|
||||
}
|
||||
|
||||
panel.classList.remove("hide");
|
||||
panel.classList.add("is-active");
|
||||
|
||||
const mount = panel.querySelector('[data-role="request-mount"]');
|
||||
if (!mount) {
|
||||
return;
|
||||
@@ -196,11 +203,32 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (window.JellyfinRequestUI) {
|
||||
window.JellyfinRequestUI.mount(mount, { embed: true });
|
||||
} else {
|
||||
if (!window.JellyfinRequestUI) {
|
||||
mount.textContent = "Request UI failed to initialize.";
|
||||
return;
|
||||
}
|
||||
|
||||
const needsForce = forceRemount || !mount.querySelector(".req-root");
|
||||
window.JellyfinRequestUI.mount(mount, { embed: true, force: needsForce });
|
||||
}
|
||||
|
||||
function showRequestPanel() {
|
||||
const page = document.getElementById("indexPage");
|
||||
const button = document.querySelector(`.headerTabs [${TAB_ATTR}="request"]`);
|
||||
const panel = page?.querySelector(`.tabContent[${TAB_ATTR}="request"]`);
|
||||
if (!button || !panel) {
|
||||
return;
|
||||
}
|
||||
|
||||
const index = parseInt(button.getAttribute("data-index"), 10);
|
||||
if (!isNaN(index)) {
|
||||
syncPanelVisibility(index);
|
||||
} else {
|
||||
panel.classList.remove("hide");
|
||||
panel.classList.add("is-active");
|
||||
}
|
||||
|
||||
mountRequestUi(panel, true);
|
||||
}
|
||||
|
||||
function isRequestTabButton(button) {
|
||||
@@ -231,9 +259,7 @@
|
||||
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);
|
||||
}
|
||||
mountRequestUi(panel, false);
|
||||
}
|
||||
}, true);
|
||||
|
||||
@@ -256,9 +282,7 @@
|
||||
event.stopImmediatePropagation();
|
||||
syncPanelVisibility(index);
|
||||
const panel = document.querySelector(`.tabContent[${TAB_ATTR}="request"]`);
|
||||
if (panel) {
|
||||
mountRequestUi(panel);
|
||||
}
|
||||
mountRequestUi(panel, true);
|
||||
}, true);
|
||||
}
|
||||
|
||||
@@ -360,6 +384,14 @@
|
||||
button = createTabButton();
|
||||
}
|
||||
|
||||
if (button.dataset.jfRequestClickBound !== "1") {
|
||||
button.dataset.jfRequestClickBound = "1";
|
||||
button.addEventListener("click", () => {
|
||||
setTimeout(showRequestPanel, 0);
|
||||
setTimeout(showRequestPanel, 120);
|
||||
});
|
||||
}
|
||||
|
||||
let panel = page.querySelector(`.tabContent[${TAB_ATTR}="request"]`);
|
||||
if (!panel) {
|
||||
panel = createTabPanel();
|
||||
|
||||
Reference in new issue
Block a user