Skip to content

Commit

Permalink
Increase amount of home sections from 7 to 10
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed Sep 21, 2024
1 parent 2d5b0ea commit a269dcb
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/components/homeScreenSettings/homeScreenSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import toast from '../toast/toast';
import template from './homeScreenSettings.template.html';
import { LibraryTab } from '../../types/libraryTab.ts';

const numConfigurableSections = 7;
const numConfigurableSections = 10;

function renderViews(page, user, result) {
let folderHtml = '';
Expand Down Expand Up @@ -204,15 +204,15 @@ function renderViewOrder(context, user, result) {
}

function updateHomeSectionValues(context, userSettings) {
for (let i = 1; i <= 7; i++) {
for (let i = 1; i <= numConfigurableSections; i++) {
const select = context.querySelector(`#selectHomeSection${i}`);
const defaultValue = homeSections.getDefaultSection(i - 1);

const option = select.querySelector(`option[value=${defaultValue}]`) || select.querySelector('option[value=""]');
const option = select.querySelector(`option[value="${defaultValue}"]`) || select.querySelector('option[value=""]');

const userValue = userSettings.get(`homesection${i - 1}`);

option.value = '';
if (option) option.value = '';

if (userValue === defaultValue || !userValue) {
select.value = '';
Expand Down Expand Up @@ -390,6 +390,9 @@ function saveUser(context, user, userSettingsInstance, apiClient) {
userSettingsInstance.set('homesection4', context.querySelector('#selectHomeSection5').value);
userSettingsInstance.set('homesection5', context.querySelector('#selectHomeSection6').value);
userSettingsInstance.set('homesection6', context.querySelector('#selectHomeSection7').value);
userSettingsInstance.set('homesection7', context.querySelector('#selectHomeSection8').value);
userSettingsInstance.set('homesection8', context.querySelector('#selectHomeSection9').value);
userSettingsInstance.set('homesection9', context.querySelector('#selectHomeSection10').value);

const selectLandings = context.querySelectorAll('.selectLanding');
for (i = 0, length = selectLandings.length; i < length; i++) {
Expand Down
42 changes: 42 additions & 0 deletions src/components/homeScreenSettings/homeScreenSettings.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,48 @@ <h2 class="sectionTitle">${Home}</h2>
<option value="none">${None}</option>
</select>
</div>
<div class="selectContainer">
<select is="emby-select" id="selectHomeSection8" label="{section8label}">
<option value="smalllibrarytiles">${HeaderMyMedia}</option>
<option value="librarybuttons">${HeaderMyMediaSmall}</option>
<option value="activerecordings">${HeaderActiveRecordings}</option>
<option value="resume">${HeaderContinueWatching}</option>
<option value="resumeaudio">${HeaderContinueListening}</option>
<option value="resumebook">${HeaderContinueReading}</option>
<option value="latestmedia">${HeaderLatestMedia}</option>
<option value="nextup">${NextUp}</option>
<option value="livetv">${LiveTV}</option>
<option value="none">${None}</option>
</select>
</div>
<div class="selectContainer">
<select is="emby-select" id="selectHomeSection9" label="{section9label}">
<option value="smalllibrarytiles">${HeaderMyMedia}</option>
<option value="librarybuttons">${HeaderMyMediaSmall}</option>
<option value="activerecordings">${HeaderActiveRecordings}</option>
<option value="resume">${HeaderContinueWatching}</option>
<option value="resumeaudio">${HeaderContinueListening}</option>
<option value="resumebook">${HeaderContinueReading}</option>
<option value="latestmedia">${HeaderLatestMedia}</option>
<option value="nextup">${NextUp}</option>
<option value="livetv">${LiveTV}</option>
<option value="none">${None}</option>
</select>
</div>
<div class="selectContainer">
<select is="emby-select" id="selectHomeSection10" label="{section10label}">
<option value="smalllibrarytiles">${HeaderMyMedia}</option>
<option value="librarybuttons">${HeaderMyMediaSmall}</option>
<option value="activerecordings">${HeaderActiveRecordings}</option>
<option value="resume">${HeaderContinueWatching}</option>
<option value="resumeaudio">${HeaderContinueListening}</option>
<option value="resumebook">${HeaderContinueReading}</option>
<option value="latestmedia">${HeaderLatestMedia}</option>
<option value="nextup">${NextUp}</option>
<option value="livetv">${LiveTV}</option>
<option value="none">${None}</option>
</select>
</div>
</div>

<div class="verticalSection verticalSection-extrabottompadding">
Expand Down
2 changes: 1 addition & 1 deletion src/components/homesections/homesections.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function loadSections(elem, apiClient, user, userSettings) {
let html = '';

if (userViews.length) {
const userSectionCount = 7;
const userSectionCount = 10;
// TV layout can have an extra section to ensure libraries are visible
const totalSectionCount = layoutManager.tv ? userSectionCount + 1 : userSectionCount;
for (let i = 0; i < totalSectionCount; i++) {
Expand Down

0 comments on commit a269dcb

Please sign in to comment.