mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 17:15:48 +00:00
redirects from /continuewatching fixed
This commit is contained in:
parent
a0367c8b66
commit
d63b028903
2 changed files with 15 additions and 13 deletions
|
|
@ -7,12 +7,12 @@ const useLibrary = require('./useLibrary');
|
|||
const useSelectableInputs = require('./useSelectableInputs');
|
||||
const styles = require('./styles');
|
||||
|
||||
const Library = ({ model, urlParams, queryParams }) => {
|
||||
const Library = ({ model, route, urlParams, queryParams }) => {
|
||||
const profile = useProfile();
|
||||
const library = useLibrary(model, urlParams, queryParams);
|
||||
const [typeSelect, sortSelect] = useSelectableInputs(library);
|
||||
const [typeSelect, sortSelect] = useSelectableInputs(route, library);
|
||||
return (
|
||||
<MainNavBars className={styles['library-container']} route={'library'}>
|
||||
<MainNavBars className={styles['library-container']} route={route}>
|
||||
<div className={styles['library-content']}>
|
||||
{
|
||||
profile.auth !== null && library.type_names.length > 0 ?
|
||||
|
|
@ -60,6 +60,7 @@ const Library = ({ model, urlParams, queryParams }) => {
|
|||
|
||||
Library.propTypes = {
|
||||
model: PropTypes.string,
|
||||
route: PropTypes.string,
|
||||
urlParams: PropTypes.shape({
|
||||
type: PropTypes.string
|
||||
}),
|
||||
|
|
@ -67,23 +68,24 @@ Library.propTypes = {
|
|||
};
|
||||
|
||||
module.exports = ({ urlParams, queryParams }) => {
|
||||
const model = React.useMemo(() => {
|
||||
const [model, route] = React.useMemo(() => {
|
||||
return typeof urlParams.path === 'string' ?
|
||||
urlParams.path.match(routesRegexp.library.regexp) ?
|
||||
'library'
|
||||
['library', 'library']
|
||||
:
|
||||
urlParams.path.match(routesRegexp.continuewatching.regexp) ?
|
||||
'continue_watching'
|
||||
['continue_watching', 'continuewatching']
|
||||
:
|
||||
null
|
||||
[null, null]
|
||||
:
|
||||
null;
|
||||
[null, null];
|
||||
}, [urlParams.path]);
|
||||
if (typeof model === 'string') {
|
||||
return (
|
||||
<Library
|
||||
key={model}
|
||||
model={model}
|
||||
route={route}
|
||||
urlParams={urlParams}
|
||||
queryParams={queryParams}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ const SORT_OPTIONS = [
|
|||
{ label: 'Watched', value: 'timeswatched' },
|
||||
];
|
||||
|
||||
const mapSelectableInputs = (library) => {
|
||||
const mapSelectableInputs = (route, library) => {
|
||||
const typeSelect = {
|
||||
title: 'Select type',
|
||||
selected: library.selected !== null ?
|
||||
|
|
@ -18,7 +18,7 @@ const mapSelectableInputs = (library) => {
|
|||
onSelect: (event) => {
|
||||
const type = JSON.parse(event.value);
|
||||
const queryParams = new URLSearchParams(library.selected !== null ? [['sort', library.selected.sort]] : []);
|
||||
window.location.replace(`#/library${type !== null ? `/${encodeURIComponent(type)}` : ''}?${queryParams.toString()}`);
|
||||
window.location.replace(`#/${route}${type !== null ? `/${encodeURIComponent(type)}` : ''}?${queryParams.toString()}`);
|
||||
}
|
||||
};
|
||||
const sortSelect = {
|
||||
|
|
@ -31,15 +31,15 @@ const mapSelectableInputs = (library) => {
|
|||
onSelect: (event) => {
|
||||
const type = library.selected !== null ? library.selected.type_name : null;
|
||||
const queryParams = new URLSearchParams([['sort', event.value]]);
|
||||
window.location.replace(`#/library${type !== null ? `/${encodeURIComponent(type)}` : ''}?${queryParams.toString()}`);
|
||||
window.location.replace(`#/${route}${type !== null ? `/${encodeURIComponent(type)}` : ''}?${queryParams.toString()}`);
|
||||
}
|
||||
};
|
||||
return [typeSelect, sortSelect];
|
||||
};
|
||||
|
||||
const useSelectableInputs = (library) => {
|
||||
const useSelectableInputs = (route, library) => {
|
||||
const selectableInputs = React.useMemo(() => {
|
||||
return mapSelectableInputs(library);
|
||||
return mapSelectableInputs(route, library);
|
||||
}, [library]);
|
||||
return selectableInputs;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue