mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +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 useSelectableInputs = require('./useSelectableInputs');
|
||||||
const styles = require('./styles');
|
const styles = require('./styles');
|
||||||
|
|
||||||
const Library = ({ model, urlParams, queryParams }) => {
|
const Library = ({ model, route, urlParams, queryParams }) => {
|
||||||
const profile = useProfile();
|
const profile = useProfile();
|
||||||
const library = useLibrary(model, urlParams, queryParams);
|
const library = useLibrary(model, urlParams, queryParams);
|
||||||
const [typeSelect, sortSelect] = useSelectableInputs(library);
|
const [typeSelect, sortSelect] = useSelectableInputs(route, library);
|
||||||
return (
|
return (
|
||||||
<MainNavBars className={styles['library-container']} route={'library'}>
|
<MainNavBars className={styles['library-container']} route={route}>
|
||||||
<div className={styles['library-content']}>
|
<div className={styles['library-content']}>
|
||||||
{
|
{
|
||||||
profile.auth !== null && library.type_names.length > 0 ?
|
profile.auth !== null && library.type_names.length > 0 ?
|
||||||
|
|
@ -60,6 +60,7 @@ const Library = ({ model, urlParams, queryParams }) => {
|
||||||
|
|
||||||
Library.propTypes = {
|
Library.propTypes = {
|
||||||
model: PropTypes.string,
|
model: PropTypes.string,
|
||||||
|
route: PropTypes.string,
|
||||||
urlParams: PropTypes.shape({
|
urlParams: PropTypes.shape({
|
||||||
type: PropTypes.string
|
type: PropTypes.string
|
||||||
}),
|
}),
|
||||||
|
|
@ -67,23 +68,24 @@ Library.propTypes = {
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = ({ urlParams, queryParams }) => {
|
module.exports = ({ urlParams, queryParams }) => {
|
||||||
const model = React.useMemo(() => {
|
const [model, route] = React.useMemo(() => {
|
||||||
return typeof urlParams.path === 'string' ?
|
return typeof urlParams.path === 'string' ?
|
||||||
urlParams.path.match(routesRegexp.library.regexp) ?
|
urlParams.path.match(routesRegexp.library.regexp) ?
|
||||||
'library'
|
['library', 'library']
|
||||||
:
|
:
|
||||||
urlParams.path.match(routesRegexp.continuewatching.regexp) ?
|
urlParams.path.match(routesRegexp.continuewatching.regexp) ?
|
||||||
'continue_watching'
|
['continue_watching', 'continuewatching']
|
||||||
:
|
:
|
||||||
null
|
[null, null]
|
||||||
:
|
:
|
||||||
null;
|
[null, null];
|
||||||
}, [urlParams.path]);
|
}, [urlParams.path]);
|
||||||
if (typeof model === 'string') {
|
if (typeof model === 'string') {
|
||||||
return (
|
return (
|
||||||
<Library
|
<Library
|
||||||
key={model}
|
key={model}
|
||||||
model={model}
|
model={model}
|
||||||
|
route={route}
|
||||||
urlParams={urlParams}
|
urlParams={urlParams}
|
||||||
queryParams={queryParams}
|
queryParams={queryParams}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ const SORT_OPTIONS = [
|
||||||
{ label: 'Watched', value: 'timeswatched' },
|
{ label: 'Watched', value: 'timeswatched' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const mapSelectableInputs = (library) => {
|
const mapSelectableInputs = (route, library) => {
|
||||||
const typeSelect = {
|
const typeSelect = {
|
||||||
title: 'Select type',
|
title: 'Select type',
|
||||||
selected: library.selected !== null ?
|
selected: library.selected !== null ?
|
||||||
|
|
@ -18,7 +18,7 @@ const mapSelectableInputs = (library) => {
|
||||||
onSelect: (event) => {
|
onSelect: (event) => {
|
||||||
const type = JSON.parse(event.value);
|
const type = JSON.parse(event.value);
|
||||||
const queryParams = new URLSearchParams(library.selected !== null ? [['sort', library.selected.sort]] : []);
|
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 = {
|
const sortSelect = {
|
||||||
|
|
@ -31,15 +31,15 @@ const mapSelectableInputs = (library) => {
|
||||||
onSelect: (event) => {
|
onSelect: (event) => {
|
||||||
const type = library.selected !== null ? library.selected.type_name : null;
|
const type = library.selected !== null ? library.selected.type_name : null;
|
||||||
const queryParams = new URLSearchParams([['sort', event.value]]);
|
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];
|
return [typeSelect, sortSelect];
|
||||||
};
|
};
|
||||||
|
|
||||||
const useSelectableInputs = (library) => {
|
const useSelectableInputs = (route, library) => {
|
||||||
const selectableInputs = React.useMemo(() => {
|
const selectableInputs = React.useMemo(() => {
|
||||||
return mapSelectableInputs(library);
|
return mapSelectableInputs(route, library);
|
||||||
}, [library]);
|
}, [library]);
|
||||||
return selectableInputs;
|
return selectableInputs;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue