Merge pull request #839 from Stremio/fix/library-default-filter

Library: Default type All filter
This commit is contained in:
Timothy Z. 2025-04-15 11:58:00 +03:00 committed by GitHub
commit e6bd8d66e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View file

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

View file

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