fix(Library): default to type All filter after selected type is no longer available

This commit is contained in:
Botzy 2025-02-18 18:05:18 +02:00
parent dfe509d93f
commit b8c328507e
2 changed files with 10 additions and 3 deletions

View file

@ -62,6 +62,11 @@ const Library = ({ model, urlParams, queryParams }) => {
scrollContainerRef.current.scrollTop = 0;
}
}, [profile.auth, library.selected]);
React.useEffect(() => {
if (!library.selected?.type && typeSelect.selected) {
window.location = typeSelect.selected[0];
}
}, [typeSelect.selected, library.selected]);
return (
<MainNavBars className={styles['library-container']} route={model}>
<div className={styles['library-content']}>

View file

@ -4,6 +4,8 @@ const React = require('react');
const { useTranslate } = require('stremio/common');
const mapSelectableInputs = (library, t) => {
const selectedType = library.selectable.types
.filter(({ selected }) => selected).map(({ deepLinks }) => deepLinks.library);
const typeSelect = {
title: t.string('SELECT_TYPE'),
options: library.selectable.types
@ -11,9 +13,9 @@ const mapSelectableInputs = (library, t) => {
value: deepLinks.library,
label: type === null ? t.string('TYPE_ALL') : t.stringWithPrefix(type, 'TYPE_')
})),
selected: library.selectable.types
.filter(({ selected }) => selected)
.map(({ deepLinks }) => deepLinks.library),
selected: selectedType.length
? selectedType
: [library.selectable.types[0]].map(({ deepLinks }) => deepLinks.library),
onSelect: (event) => {
window.location = event.value;
}