feat: open show in new tab

This commit is contained in:
ner committed 2024-11-16 19:16:55 +02:00
1 parent 063a2494ae
commit c550f1e29e
2 files changed
+20 -6

No files matched your search

@@ -1,9 +1,10 @@
'use client'; 'use client';
import { Bookmark, Heart, Link, Play, Star } from 'lucide-react'; import { Bookmark, ExternalLink, Heart, Link, Play, Star } from 'lucide-react';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import ButtonsGroup from '@/components/ui/buttons-group'; import ButtonsGroup from '@/components/ui/buttons-group';
import { SITE_URL } from '@/env';
import useShowState, { useMutateShowState } from '@/hooks/useShowState'; import useShowState, { useMutateShowState } from '@/hooks/useShowState';
import { useToast } from '@/hooks/useToast'; import { useToast } from '@/hooks/useToast';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
@@ -30,8 +31,8 @@ const Actions = ({ show, className }: Props) => {
</ButtonsGroup> </ButtonsGroup>
<ButtonsGroup> <ButtonsGroup>
<Button <Button
aria-label='Toggle favorite' aria-label={`${state?.favorite ? 'Remove from' : 'Add to'} favorites`}
title='Toggle favorite' title={`${state?.favorite ? 'Remove from' : 'Add to'} favorites`}
variant='outline' variant='outline'
disabled={toggle.list === 'favorite' && toggle.isPending} disabled={toggle.list === 'favorite' && toggle.isPending}
onClick={() => toggle.mutate({ list: 'favorite', value: !state?.favorite })} onClick={() => toggle.mutate({ list: 'favorite', value: !state?.favorite })}
@@ -39,8 +40,8 @@ const Actions = ({ show, className }: Props) => {
<Heart size={14} className={cn({ 'fill-secondary-foreground': state?.favorite })} /> <Heart size={14} className={cn({ 'fill-secondary-foreground': state?.favorite })} />
</Button> </Button>
<Button <Button
aria-label='Toggle watch list' aria-label={`${state?.watchlist ? 'Remove from' : 'Add to'} watch list`}
title='Toggle watch list' title={`${state?.watchlist ? 'Remove from' : 'Add to'} watch list`}
variant='outline' variant='outline'
disabled={toggle.list === 'watchlist' && toggle.isPending} disabled={toggle.list === 'watchlist' && toggle.isPending}
onClick={() => toggle.mutate({ list: 'watchlist', value: !state?.watchlist })} onClick={() => toggle.mutate({ list: 'watchlist', value: !state?.watchlist })}
@@ -48,6 +49,7 @@ const Actions = ({ show, className }: Props) => {
<Bookmark size={14} className={cn({ 'fill-secondary-foreground': state?.watchlist })} /> <Bookmark size={14} className={cn({ 'fill-secondary-foreground': state?.watchlist })} />
</Button> </Button>
</ButtonsGroup> </ButtonsGroup>
<ButtonsGroup className='ml-auto sm:ml-0'>
<Button <Button
aria-label='Copy link' aria-label='Copy link'
title='Copy link' title='Copy link'
@@ -61,6 +63,17 @@ const Actions = ({ show, className }: Props) => {
> >
<Link size={14} /> <Link size={14} />
</Button> </Button>
<Button aria-label='Open in new tab' title='Open in new tab' variant='outline' className='relative h-8 px-3'>
<a
className='absolute left-0 top-0 size-full'
target='_blank'
rel='noopener noreferrer'
href={`${SITE_URL}/${show.type}/${show.id}`}
/>
<ExternalLink size={14} />
</Button>
</ButtonsGroup>
<ButtonsGroup className='ml-auto sm:ml-0'> <ButtonsGroup className='ml-auto sm:ml-0'>
<Button <Button
aria-label='Watch' aria-label='Watch'
@@ -57,12 +57,13 @@ const Actions: FC<Props> = ({ torrent, backdrop, title, provider }) => {
<a <a
className='absolute left-0 top-0 size-full' className='absolute left-0 top-0 size-full'
target='_blank' target='_blank'
rel='noopener noreferrer'
href={`${STREAM_URL}?m3u&link=${encodeURIComponent(magnet)}`} href={`${STREAM_URL}?m3u&link=${encodeURIComponent(magnet)}`}
/> />
<ListVideo size={20} /> <ListVideo size={20} />
</Button> </Button>
<Button className='relative grow-0 px-3' variant='outline' title='Download magnet'> <Button className='relative grow-0 px-3' variant='outline' title='Download magnet'>
<a className='absolute left-0 top-0 size-full' target='_blank' href={magnet} /> <a className='absolute left-0 top-0 size-full' target='_blank' rel='noopener noreferrer' href={magnet} />
<Magnet size={20} /> <Magnet size={20} />
</Button> </Button>
{supportedForCast && ( {supportedForCast && (