feat(LibItem): use navigate instead window location

This commit is contained in:
Botzy 2025-05-13 15:36:44 +03:00
parent 9a3ac82479
commit 173745042c

View file

@ -1,14 +1,15 @@
// Copyright (C) 2017-2023 Smart code 203358507
const React = require('react');
const { useNavigate } = require('react-router');
const { useServices } = require('stremio/services');
const PropTypes = require('prop-types');
const MetaItem = require('stremio/components/MetaItem');
const { t } = require('i18next');
const LibItem = ({ _id, removable, notifications, watched, ...props }) => {
const { core } = useServices();
const navigate = useNavigate();
const newVideos = React.useMemo(() => {
const count = notifications.items?.[_id]?.length ?? 0;
@ -50,7 +51,8 @@ const LibItem = ({ _id, removable, notifications, watched, ...props }) => {
switch (event.value) {
case 'play': {
if (props.deepLinks && typeof props.deepLinks.player === 'string') {
window.location = props.deepLinks.player;
// TODO: remove # from deeplinks in core for web?
navigate(props.deepLinks.player.replace('#', ''));
}
break;
@ -58,9 +60,9 @@ const LibItem = ({ _id, removable, notifications, watched, ...props }) => {
case 'details': {
if (props.deepLinks) {
if (typeof props.deepLinks.metaDetailsVideos === 'string') {
window.location = props.deepLinks.metaDetailsVideos;
navigate(props.deepLinks.metaDetailsVideos.replace('#', ''));
} else if (typeof props.deepLinks.metaDetailsStreams === 'string') {
window.location = props.deepLinks.metaDetailsStreams;
navigate(props.deepLinks.metaDetailsStreams.replace('#', ''));
}
}