mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 17:15:48 +00:00
Merge pull request #839 from Stremio/fix/library-default-filter
Library: Default type All filter
This commit is contained in:
commit
e6bd8d66e8
2 changed files with 10 additions and 3 deletions
|
|
@ -63,6 +63,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}>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue