Skip to content

Commit

Permalink
fix(Library): default to type All filter after selected type is no lo…
Browse files Browse the repository at this point in the history
…nger available
  • Loading branch information
Botsy committed Feb 18, 2025
1 parent dfe509d commit b8c3285
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/routes/Library/Library.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']}>
Expand Down
8 changes: 5 additions & 3 deletions src/routes/Library/useSelectableInputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ 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
.map(({ type, deepLinks }) => ({
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;
}
Expand Down

0 comments on commit b8c3285

Please sign in to comment.