mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-14 09:00:30 +00:00
feat(MetaDetails): use navigate instead window location
This commit is contained in:
parent
d1c95142f9
commit
2a823711df
2 changed files with 15 additions and 11 deletions
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2017-2023 Smart code 203358507
|
||||
|
||||
const React = require('react');
|
||||
const { useParams } = require('react-router');
|
||||
const { useParams, useLocation, useNavigate } = require('react-router');
|
||||
const classnames = require('classnames');
|
||||
const { useServices } = require('stremio/services');
|
||||
const { withCoreSuspender } = require('stremio/common');
|
||||
|
|
@ -15,6 +15,8 @@ const styles = require('./styles');
|
|||
|
||||
const MetaDetails = () => {
|
||||
const urlParams = useParams();
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const { core } = useServices();
|
||||
const metaDetails = useMetaDetails(urlParams);
|
||||
const [season, setSeason] = useSeason(urlParams);
|
||||
|
|
@ -79,10 +81,11 @@ const MetaDetails = () => {
|
|||
}, [setSeason]);
|
||||
const handleEpisodeSearch = React.useCallback((season, episode) => {
|
||||
const searchVideoHash = encodeURIComponent(`${urlParams.id}:${season}:${episode}`);
|
||||
const url = window.location.hash;
|
||||
const url = location.hash;
|
||||
console.log(location);
|
||||
const searchVideoPath = url.replace(encodeURIComponent(urlParams.videoId), searchVideoHash);
|
||||
window.location = searchVideoPath;
|
||||
}, [urlParams, window.location]);
|
||||
navigate(searchVideoPath.replace('#', ''));
|
||||
}, [urlParams, location]);
|
||||
|
||||
const renderBackgroundImageFallback = React.useCallback(() => null, []);
|
||||
const renderBackground = React.useMemo(() => !!(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (C) 2017-2023 Smart code 203358507
|
||||
|
||||
const React = require('react');
|
||||
const { useNavigate } = require('react-router');
|
||||
const PropTypes = require('prop-types');
|
||||
const classnames = require('classnames');
|
||||
const { useTranslation } = require('react-i18next');
|
||||
|
|
@ -19,6 +20,7 @@ const StreamsList = ({ className, video, type, onEpisodeSearch, ...props }) => {
|
|||
const { core } = useServices();
|
||||
const platform = usePlatform();
|
||||
const profile = useProfile();
|
||||
const navigate = useNavigate();
|
||||
const streamsContainerRef = React.useRef(null);
|
||||
const [selectedAddon, setSelectedAddon] = React.useState(ALL_ADDONS_KEY);
|
||||
const onAddonSelected = React.useCallback((event) => {
|
||||
|
|
@ -30,14 +32,13 @@ const StreamsList = ({ className, video, type, onEpisodeSearch, ...props }) => {
|
|||
}, [profile, video]);
|
||||
const backButtonOnClick = React.useCallback(() => {
|
||||
if (video.deepLinks && typeof video.deepLinks.metaDetailsVideos === 'string') {
|
||||
window.location.replace(video.deepLinks.metaDetailsVideos + (
|
||||
typeof video.season === 'number' ?
|
||||
`?${new URLSearchParams({ 'season': video.season })}`
|
||||
:
|
||||
null
|
||||
));
|
||||
const navigateTo = `${video.deepLinks.metaDetailsVideos}${
|
||||
typeof video.season === 'number'
|
||||
? `?${new URLSearchParams({ 'season': video.season })}`
|
||||
: ''}`;
|
||||
navigate(navigateTo.replace('#', ''));
|
||||
} else {
|
||||
window.history.back();
|
||||
navigate(-1);
|
||||
}
|
||||
}, [video]);
|
||||
const countLoadingAddons = React.useMemo(() => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue