- {selectInputs.map(({ title, options, selected, renderLabelText, onSelect }, index) => (
- (
+
))}
@@ -187,14 +186,13 @@ const Discover = ({ urlParams, queryParams }) => {
{
inputsModalOpen ?
- {selectInputs.map(({ title, options, selected, renderLabelText, onSelect }, index) => (
- (
+
))}
diff --git a/src/routes/Discover/styles.less b/src/routes/Discover/styles.less
index 62e3adaee..14012d5cd 100644
--- a/src/routes/Discover/styles.less
+++ b/src/routes/Discover/styles.less
@@ -50,6 +50,7 @@
.select-input {
flex: 0 1 15rem;
+ background-color: var(--overlay-color);
&:not(:first-child) {
margin-left: 1.5rem;
diff --git a/src/routes/Discover/useSelectableInputs.js b/src/routes/Discover/useSelectableInputs.js
index 18d317507..459e095cf 100644
--- a/src/routes/Discover/useSelectableInputs.js
+++ b/src/routes/Discover/useSelectableInputs.js
@@ -4,72 +4,79 @@ const React = require('react');
const { useTranslate } = require('stremio/common');
const mapSelectableInputs = (discover, t) => {
+ const selectedType = discover.selectable.types.find(({ selected }) => selected);
const typeSelect = {
- title: t.string('SELECT_TYPE'),
options: discover.selectable.types
.map(({ type, deepLinks }) => ({
value: deepLinks.discover,
label: t.stringWithPrefix(type, 'TYPE_')
})),
- selected: discover.selectable.types
- .filter(({ selected }) => selected)
- .map(({ deepLinks }) => deepLinks.discover),
- renderLabelText: discover.selected !== null ?
- () => t.stringWithPrefix(discover.selected.request.path.type, 'TYPE_')
- :
- null,
- onSelect: (event) => {
- window.location = event.value;
+ selectedOption: selectedType
+ ? {
+ label: t.stringWithPrefix(selectedType.type, 'TYPE_'),
+ value: selectedType.deepLinks.discover,
+ }
+ : undefined,
+ title: discover.selected !== null
+ ? () => t.stringWithPrefix(discover.selected.request.path.type, 'TYPE_')
+ : t.string('SELECT_TYPE'),
+ onSelect: (value) => {
+ window.location = value;
}
};
+ const selectedCatalog = discover.selectable.catalogs.find(({ selected }) => selected);
const catalogSelect = {
- title: t.string('SELECT_CATALOG'),
options: discover.selectable.catalogs
.map(({ id, name, addon, deepLinks }) => ({
value: deepLinks.discover,
label: t.catalogTitle({ addon, id, name }),
title: `${name} (${addon.manifest.name})`
})),
- selected: discover.selectable.catalogs
- .filter(({ selected }) => selected)
- .map(({ deepLinks }) => deepLinks.discover),
- renderLabelText: discover.selected !== null ?
- () => {
+ selectedOption: discover.selected?.request.path.id
+ ? {
+ label: t.catalogTitle({ addon: selectedCatalog.addon, id: selectedCatalog.id, name: selectedCatalog.name }),
+ value: selectedCatalog.deepLinks.discover
+ }
+ : undefined,
+ title: discover.selected !== null
+ ? () => {
const selectableCatalog = discover.selectable.catalogs
.find(({ id }) => id === discover.selected.request.path.id);
return selectableCatalog ? t.catalogTitle(selectableCatalog, false) : discover.selected.request.path.id;
}
:
- null,
- onSelect: (event) => {
- window.location = event.value;
+ t.string('SELECT_CATALOG'),
+ onSelect: (value) => {
+ window.location =value;
}
};
- const extraSelects = discover.selectable.extra.map(({ name, isRequired, options }) => ({
- title: t.stringWithPrefix(name, 'SELECT_'),
- isRequired: isRequired,
- options: options.map(({ value, deepLinks }) => ({
- label: typeof value === 'string' ? t.stringWithPrefix(value) : t.string('NONE'),
- value: JSON.stringify({
- href: deepLinks.discover,
- value
- })
- })),
- selected: options
- .filter(({ selected }) => selected)
- .map(({ value, deepLinks }) => JSON.stringify({
- href: deepLinks.discover,
- value
+ const extraSelects = discover.selectable.extra.map(({ name, isRequired, options }) => {
+ const selectedExtra = options.find(({ selected }) => selected);
+ return {
+ isRequired: isRequired,
+ options: options.map(({ value, deepLinks }) => ({
+ label: typeof value === 'string' ? t.stringWithPrefix(value) : t.string('NONE'),
+ value: JSON.stringify({
+ href: deepLinks.discover,
+ value
+ })
})),
- renderLabelText: options.some(({ selected, value }) => selected && value === null) ?
- () => t.stringWithPrefix(name, 'SELECT_')
- :
- null,
- onSelect: (event) => {
- const { href } = JSON.parse(event.value);
- window.location = href;
- }
- }));
+ selectedOption: {
+ label: typeof selectedExtra.value === 'string' ? t.stringWithPrefix(selectedExtra.value) : t.string('NONE'),
+ value: JSON.stringify({
+ href: selectedExtra.deepLinks.discover,
+ value: selectedExtra.value,
+ })
+ },
+ title: options.some(({ selected, value }) => selected && value === null) ?
+ () => t.stringWithPrefix(name, 'SELECT_')
+ : t.stringWithPrefix(selectedExtra.value),
+ onSelect: (value) => {
+ const { href } = JSON.parse(value);
+ window.location = href;
+ }
+ };
+ });
return [[typeSelect, catalogSelect, ...extraSelects], discover.selectable.nextPage];
};