mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +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;
|
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}>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue