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

Fix maximum allowed parental rating not showing up

This commit is contained in:
viown 2024-11-27 16:50:41 +03:00
parent d56ff77308
commit 9e4e3b0106

View file

@ -65,6 +65,7 @@ const UserParentalControl = () => {
const [ userName, setUserName ] = useState('');
const [ parentalRatings, setParentalRatings ] = useState<ParentalRating[]>([]);
const [ unratedItems, setUnratedItems ] = useState<UnratedNamedItem[]>([]);
const [ maxParentalRating, setMaxParentalRating ] = useState<string>();
const [ accessSchedules, setAccessSchedules ] = useState<AccessSchedule[]>([]);
const [ allowedTags, setAllowedTags ] = useState<string[]>([]);
const [ blockedTags, setBlockedTags ] = useState<string[]>([]);
@ -163,15 +164,15 @@ const UserParentalControl = () => {
populateRatings(allParentalRatings);
let ratingValue = '';
if (user.Policy?.MaxParentalRating) {
if (user.Policy?.MaxParentalRating != null) {
allParentalRatings.forEach(rating => {
if (rating.Value && user.Policy?.MaxParentalRating && user.Policy.MaxParentalRating >= rating.Value) {
if (rating.Value != null && user.Policy?.MaxParentalRating != null && user.Policy.MaxParentalRating >= rating.Value) {
ratingValue = `${rating.Value}`;
}
});
}
(page.querySelector('#selectMaxParentalRating') as HTMLSelectElement).value = String(ratingValue);
setMaxParentalRating(ratingValue);
if (user.Policy?.IsAdministrator) {
(page.querySelector('.accessScheduleSection') as HTMLDivElement).classList.add('hide');
@ -329,11 +330,24 @@ const UserParentalControl = () => {
};
}, [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 = () => {
let content = '';
content += '<option value=\'\'></option>';
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;
};