mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-19 09:42:13 +00:00
using one function for all select inputs in discover
This commit is contained in:
parent
1a8ed55992
commit
d12cc21334
1 changed files with 6 additions and 8 deletions
|
|
@ -14,6 +14,10 @@ const useCatalog = (urlParams, queryParams) => {
|
|||
const type = typeof urlParams.type === 'string' ? urlParams.type : DEFAULT_TYPE;
|
||||
const onNewModel = () => {
|
||||
const state = core.getState();
|
||||
const onSelect = (event) => {
|
||||
const load = JSON.parse(event.value);
|
||||
window.location = `#/discover/${encodeURIComponent(load.base)}/${encodeURIComponent(load.path.id)}/${encodeURIComponent(load.path.type_name)}`;
|
||||
};
|
||||
const selectInputs = [
|
||||
{
|
||||
title: 'Select type',
|
||||
|
|
@ -25,10 +29,7 @@ const useCatalog = (urlParams, queryParams) => {
|
|||
selected: state.discover.types
|
||||
.filter(({ is_selected }) => is_selected)
|
||||
.map(({ load }) => JSON.stringify(load)),
|
||||
onSelect: (event) => {
|
||||
const load = JSON.parse(event.value);
|
||||
window.location = `#/discover/${encodeURIComponent(load.base)}/${encodeURIComponent(load.path.id)}/${encodeURIComponent(load.path.type_name)}`;
|
||||
}
|
||||
onSelect: onSelect
|
||||
},
|
||||
{
|
||||
title: 'Select catalog',
|
||||
|
|
@ -43,10 +44,7 @@ const useCatalog = (urlParams, queryParams) => {
|
|||
selected: state.discover.catalogs
|
||||
.filter(({ is_selected }) => is_selected)
|
||||
.map(({ load }) => JSON.stringify(load)),
|
||||
onSelect: (event) => {
|
||||
const load = JSON.parse(event.value);
|
||||
window.location = `#/discover/${encodeURIComponent(load.base)}/${encodeURIComponent(load.path.id)}/${encodeURIComponent(load.path.type_name)}`;
|
||||
}
|
||||
onSelect: onSelect
|
||||
}
|
||||
];
|
||||
const items = state.discover.content.type === 'Ready' ? state.discover.content.content : null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue