From 59aea0be001bcdc5a2024969a96cb5277252159a Mon Sep 17 00:00:00 2001 From: HighImKevin Date: Sun, 1 Feb 2026 00:38:35 -0500 Subject: [PATCH] Ensure user Home Screen display preferences are propogated to the native (hidden) select inputs --- .../homeScreen-user-configuration.js | 34 ++++++++++++++++--- injector.js | 2 +- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/configuration/homeScreen-user-configuration.js b/configuration/homeScreen-user-configuration.js index e6117f7..a124036 100644 --- a/configuration/homeScreen-user-configuration.js +++ b/configuration/homeScreen-user-configuration.js @@ -375,15 +375,39 @@ } }); + // Ensure each section has a unique jellyfinBaseId + const uniqueHomeSections = sectionsForHomesectionN.filter((section, index, self) => + index === self.findIndex(s => s.jellyfinBaseId === section.jellyfinBaseId) + ); + // Sort all sections by order - sectionsForHomesectionN.sort((a, b) => (a.order || 0) - (b.order || 0)); + uniqueHomeSections.sort((a, b) => (a.order || 0) - (b.order || 0)); // Assign each section to homesectionN sequentially - sectionsForHomesectionN.forEach((section, index) => { - if (index <= 8) { // Only homesection0 through homesection8 - customPrefs[`homesection${index}`] = section.jellyfinBaseId; + for (let i = 0; i <= 9; i++) { + const selectHomeSection = document.querySelector(`.homeScreenSettingsContainer #selectHomeSection${i+1}`); + if (i <= uniqueHomeSections.length - 1) { + const selectedSection = uniqueHomeSections[i].jellyfinBaseId; + customPrefs[`homesection${i}`] = selectedSection; + + const selectedOption = selectHomeSection.querySelector(`option[value="${selectedSection}"]`); + if (selectedOption) { + selectHomeSection.value = selectedOption.value; + } else { + selectHomeSection.value = ''; + } + } else { + customPrefs[`homesection${i}`] = 'none'; + + // Find the value of the "None" option label, some have value="none" and some have no value at all + const noneOption = selectHomeSection.querySelector('option[value="none"]'); + if (noneOption) { + selectHomeSection.value = noneOption.value; + } else { + selectHomeSection.value = ''; + } } - }); + } // Save const success = await window.userHelper.updateDisplayPreferences(displayPrefs); diff --git a/injector.js b/injector.js index 2bd2568..424e1c0 100644 --- a/injector.js +++ b/injector.js @@ -716,7 +716,7 @@ } async function loadConfigurationJS() { - const configDependencyNames = ['modal', 'toaster', 'utils', 'homeScreen-configuration', 'search-configuration', 'seriesEpisodes-configuration', 'seriesInfo-configuration', 'skinManager-configuration', 'customMenuLinks-configuration']; + const configDependencyNames = ['modal', 'toaster', 'utils', 'homeScreenConfig2', 'homeScreen-migration', 'homeScreen-configuration', 'search-configuration', 'seriesEpisodes-configuration', 'seriesInfo-configuration', 'skinManager-configuration', 'customMenuLinks-configuration']; for (const depName of configDependencyNames) { const depScript = SCRIPT_DEFINITIONS.find(script => script.name === depName); if (depScript) {