1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Backport pull request #6352 from jellyfin-web/release-10.10.z

Fix maximum allowed parental rating not showing up

Original-merge: b797ca4e1e

Merged-by: thornbill <thornbill@users.noreply.github.com>

Backported-by: thornbill <thornbill@users.noreply.github.com>
This commit is contained in:
viown 2025-01-22 03:12:40 -05:00 committed by thornbill
parent 1c114a9e18
commit 4480089d60

View file

@ -65,6 +65,7 @@ const UserParentalControl = () => {
const [ userName, setUserName ] = useState(''); const [ userName, setUserName ] = useState('');
const [ parentalRatings, setParentalRatings ] = useState<ParentalRating[]>([]); const [ parentalRatings, setParentalRatings ] = useState<ParentalRating[]>([]);
const [ unratedItems, setUnratedItems ] = useState<UnratedNamedItem[]>([]); const [ unratedItems, setUnratedItems ] = useState<UnratedNamedItem[]>([]);
const [ maxParentalRating, setMaxParentalRating ] = useState<string>();
const [ accessSchedules, setAccessSchedules ] = useState<AccessSchedule[]>([]); const [ accessSchedules, setAccessSchedules ] = useState<AccessSchedule[]>([]);
const [ allowedTags, setAllowedTags ] = useState<string[]>([]); const [ allowedTags, setAllowedTags ] = useState<string[]>([]);
const [ blockedTags, setBlockedTags ] = useState<string[]>([]); const [ blockedTags, setBlockedTags ] = useState<string[]>([]);
@ -163,15 +164,13 @@ const UserParentalControl = () => {
populateRatings(allParentalRatings); populateRatings(allParentalRatings);
let ratingValue = ''; let ratingValue = '';
if (user.Policy?.MaxParentalRating) { allParentalRatings.forEach(rating => {
allParentalRatings.forEach(rating => { if (rating.Value != null && user.Policy?.MaxParentalRating != null && user.Policy.MaxParentalRating >= rating.Value) {
if (rating.Value && user.Policy?.MaxParentalRating && user.Policy.MaxParentalRating >= rating.Value) { ratingValue = `${rating.Value}`;
ratingValue = `${rating.Value}`; }
} });
});
}
(page.querySelector('#selectMaxParentalRating') as HTMLSelectElement).value = String(ratingValue); setMaxParentalRating(ratingValue);
if (user.Policy?.IsAdministrator) { if (user.Policy?.IsAdministrator) {
(page.querySelector('.accessScheduleSection') as HTMLDivElement).classList.add('hide'); (page.querySelector('.accessScheduleSection') as HTMLDivElement).classList.add('hide');
@ -329,11 +328,24 @@ const UserParentalControl = () => {
}; };
}, [setAllowedTags, setBlockedTags, loadData, userId]); }, [setAllowedTags, setBlockedTags, loadData, userId]);
useEffect(() => {
const page = element.current;
if (!page) {
console.error('[userparentalcontrol] Unexpected null page reference');
return;
}
(page.querySelector('#selectMaxParentalRating') as HTMLSelectElement).value = String(maxParentalRating);
}, [maxParentalRating, parentalRatings]);
const optionMaxParentalRating = () => { const optionMaxParentalRating = () => {
let content = ''; let content = '';
content += '<option value=\'\'></option>'; content += '<option value=\'\'></option>';
for (const rating of parentalRatings) { for (const rating of parentalRatings) {
content += `<option value='${rating.Value}'>${escapeHTML(rating.Name)}</option>`; if (rating.Value != null) {
content += `<option value='${rating.Value}'>${escapeHTML(rating.Name)}</option>`;
}
} }
return content; return content;
}; };