refactor(MetaPreview): discover fix

This commit is contained in:
Timothy Z. 2025-06-04 14:56:11 +03:00
parent ad680ca2a5
commit beb873e34e
2 changed files with 31 additions and 25 deletions

View file

@ -27,7 +27,7 @@ const ALLOWED_LINK_REDIRECTS = [
const MetaPreview = React.forwardRef(({ className, compact, name, logo, background, runtime, releaseInfo, released, description, deepLinks, links, trailerStreams, inLibrary, toggleInLibrary, metaDetails }, ref) => {
const { t } = useTranslation();
const { onLiked, onLoved, like } = useRating(metaDetails);
const { onLiked, onLoved } = useRating(metaDetails);
const [shareModalOpen, openShareModal, closeShareModal] = useBinaryState(false);
const linksGroups = React.useMemo(() => {
return Array.isArray(links) ?
@ -222,30 +222,6 @@ const MetaPreview = React.forwardRef(({ className, compact, name, logo, backgrou
:
null
}
{
!compact ?
<ActionButton
className={styles['action-button']}
icon={'volume-medium'}
tabIndex={compact ? -1 : 0}
onClick={onLiked}
tooltip={compact}
/>
:
null
}
{
!compact ?
<ActionButton
className={styles['action-button']}
icon={'volume-high'}
tabIndex={compact ? -1 : 0}
onClick={onLoved}
tooltip={compact}
/>
:
null
}
{
typeof showHref === 'string' && compact ?
<ActionButton
@ -284,6 +260,30 @@ const MetaPreview = React.forwardRef(({ className, compact, name, logo, backgrou
:
null
}
{
!compact ?
<ActionButton
className={styles['action-button']}
icon={'volume-medium'}
tabIndex={compact ? -1 : 0}
onClick={onLiked}
tooltip={compact}
/>
:
null
}
{
!compact ?
<ActionButton
className={styles['action-button']}
icon={'volume-high'}
tabIndex={compact ? -1 : 0}
onClick={onLoved}
tooltip={compact}
/>
:
null
}
</div>
</div>
);

View file

@ -2,6 +2,12 @@ import { useMemo, useCallback } from 'react';
import { useServices } from 'stremio/services';
const useRating = (metaDetails: MetaDetails) => {
if (!metaDetails) {
return {
onLiked: () => {},
onLoved: () => {},
};
}
const { core } = useServices();
const like = useMemo(() => {