mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
fix(Library): default to type All filter after selected type is no longer available
This commit is contained in:
parent
dfe509d93f
commit
b8c328507e
2 changed files with 10 additions and 3 deletions
|
|
@ -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']}>
|
||||
|
|
|
|||
|
|
@ -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