diff --git a/src/routes/Addons/useSelectableInputs.js b/src/routes/Addons/useSelectableInputs.js index af0bb35fc..8395de636 100644 --- a/src/routes/Addons/useSelectableInputs.js +++ b/src/routes/Addons/useSelectableInputs.js @@ -1,9 +1,10 @@ // Copyright (C) 2017-2023 Smart code 203358507 const React = require('react'); +const { useNavigate } = require('react-router'); const { useTranslate } = require('stremio/common'); -const mapSelectableInputs = (installedAddons, remoteAddons, t) => { +const mapSelectableInputs = (installedAddons, remoteAddons, t, navigate) => { const catalogSelect = { title: t.string('SELECT_CATALOG'), options: remoteAddons.selectable.catalogs @@ -26,7 +27,7 @@ const mapSelectableInputs = (installedAddons, remoteAddons, t) => { : null, onSelect: (event) => { - window.location = event.value; + navigate(event.value.replace('#', '')); } }; const typeSelect = { @@ -62,7 +63,7 @@ const mapSelectableInputs = (installedAddons, remoteAddons, t) => { typeSelect.title; }, onSelect: (event) => { - window.location = event.value; + navigate(event.value.replace('#', '')); } }; return [catalogSelect, typeSelect]; @@ -70,8 +71,9 @@ const mapSelectableInputs = (installedAddons, remoteAddons, t) => { const useSelectableInputs = (installedAddons, remoteAddons) => { const t = useTranslate(); + const navigate = useNavigate(); const selectableInputs = React.useMemo(() => { - return mapSelectableInputs(installedAddons, remoteAddons, t); + return mapSelectableInputs(installedAddons, remoteAddons, t, navigate); }, [installedAddons, remoteAddons]); return selectableInputs; }; diff --git a/src/routes/Discover/useSelectableInputs.js b/src/routes/Discover/useSelectableInputs.js index 18d317507..332218d30 100644 --- a/src/routes/Discover/useSelectableInputs.js +++ b/src/routes/Discover/useSelectableInputs.js @@ -1,9 +1,10 @@ // Copyright (C) 2017-2023 Smart code 203358507 const React = require('react'); +const { useNavigate } = require('react-router'); const { useTranslate } = require('stremio/common'); -const mapSelectableInputs = (discover, t) => { +const mapSelectableInputs = (discover, t, navigate) => { const typeSelect = { title: t.string('SELECT_TYPE'), options: discover.selectable.types @@ -19,7 +20,7 @@ const mapSelectableInputs = (discover, t) => { : null, onSelect: (event) => { - window.location = event.value; + navigate(event.value.replace('#', '')); } }; const catalogSelect = { @@ -42,7 +43,7 @@ const mapSelectableInputs = (discover, t) => { : null, onSelect: (event) => { - window.location = event.value; + navigate(event.value.replace('#', '')); } }; const extraSelects = discover.selectable.extra.map(({ name, isRequired, options }) => ({ @@ -67,7 +68,7 @@ const mapSelectableInputs = (discover, t) => { null, onSelect: (event) => { const { href } = JSON.parse(event.value); - window.location = href; + navigate(href.replace('#', '')); } })); return [[typeSelect, catalogSelect, ...extraSelects], discover.selectable.nextPage]; @@ -75,8 +76,9 @@ const mapSelectableInputs = (discover, t) => { const useSelectableInputs = (discover) => { const t = useTranslate(); + const navigate = useNavigate(); const selectableInputs = React.useMemo(() => { - return mapSelectableInputs(discover, t); + return mapSelectableInputs(discover, t, navigate); }, [discover.selected, discover.selectable]); return selectableInputs; }; diff --git a/src/routes/Library/useSelectableInputs.js b/src/routes/Library/useSelectableInputs.js index d173d663a..354d2bd82 100644 --- a/src/routes/Library/useSelectableInputs.js +++ b/src/routes/Library/useSelectableInputs.js @@ -1,9 +1,10 @@ // Copyright (C) 2017-2023 Smart code 203358507 const React = require('react'); +const { useNavigate } = require('react-router'); const { useTranslate } = require('stremio/common'); -const mapSelectableInputs = (library, t) => { +const mapSelectableInputs = (library, t, navigate) => { const selectedType = library.selectable.types .filter(({ selected }) => selected).map(({ deepLinks }) => deepLinks.library); const typeSelect = { @@ -17,7 +18,7 @@ const mapSelectableInputs = (library, t) => { ? selectedType : [library.selectable.types[0]].map(({ deepLinks }) => deepLinks.library), onSelect: (event) => { - window.location = event.value; + navigate(event.value.replace('#', '')); } }; const sortChips = { @@ -30,7 +31,7 @@ const mapSelectableInputs = (library, t) => { .filter(({ selected }) => selected) .map(({ deepLinks }) => deepLinks.library), onSelect: (value) => { - window.location = value; + navigate(value.replace('#', '')); } }; return [typeSelect, sortChips, library.selectable.nextPage]; @@ -38,8 +39,9 @@ const mapSelectableInputs = (library, t) => { const useSelectableInputs = (library) => { const t = useTranslate(); + const navigate = useNavigate(); const selectableInputs = React.useMemo(() => { - return mapSelectableInputs(library, t); + return mapSelectableInputs(library, t, navigate); }, [library]); return selectableInputs; };