diff --git a/README.md b/README.md index 5ee3442..d84ecac 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ Download and Install VLC Media player form [here](https://www.videolan.org/vlc/d ## 🤝 CONTRIBUTING -Contributions, issues, and feature requests are welcome! See [See Contribution Guide.](./CONTRIBUTING.md) +Contributions, issues, and feature requests are welcome! See [Contribution Guide.](./CONTRIBUTING.md) ## ⭐ SUPPORT diff --git a/package.json b/package.json index 4bf8d69..4cd58b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lisa", - "version": "1.1.0", + "version": "2.0.0", "author": "", "description": "", "private": true, diff --git a/preload.js b/preload.js index c8f5967..96b1bd3 100644 --- a/preload.js +++ b/preload.js @@ -21,4 +21,5 @@ contextBridge.exposeInMainWorld('electronAPI', { }, openExternal: (data) => ipcRenderer.invoke('open-external', data), showItemInFolder: (data) => ipcRenderer.invoke('show-item-in-folder', data), + getPlatformOS: () => process.platform, }); diff --git a/src/components/ActiveDownloads.tsx b/src/components/ActiveDownloads.tsx index 3c2615a..3cb39ef 100644 --- a/src/components/ActiveDownloads.tsx +++ b/src/components/ActiveDownloads.tsx @@ -55,7 +55,7 @@ export function ActiveDownloads() { function ActiveDownloadsEmpty() { return ( - + diff --git a/src/components/DownloadsHistory.tsx b/src/components/DownloadsHistory.tsx index 4eb7fd5..0e45f1d 100644 --- a/src/components/DownloadsHistory.tsx +++ b/src/components/DownloadsHistory.tsx @@ -156,7 +156,7 @@ function DownloadsHistoryItem({ function DownloadsHistoryEmpty() { return ( - + diff --git a/src/hooks/useGetAnimeEpPagination.ts b/src/hooks/useGetAnimeEpPagination.ts index 33338ea..40a450b 100644 --- a/src/hooks/useGetAnimeEpPagination.ts +++ b/src/hooks/useGetAnimeEpPagination.ts @@ -25,7 +25,7 @@ export function useGetAnimeEpPagination() { stream: searchParams.get('stream'), episodePageUrl: url, }, - { replace: true }, + { replace: true, preventScrollReset: true }, ); } diff --git a/src/screens/DownloadsScreen.tsx b/src/screens/DownloadsScreen.tsx index bbdc534..24eedb0 100644 --- a/src/screens/DownloadsScreen.tsx +++ b/src/screens/DownloadsScreen.tsx @@ -1,15 +1,30 @@ import { Center, Stack } from '@chakra-ui/react'; +import { useFeatureAvailable } from 'src/utils/fn'; import { ActiveDownloads } from '../components/ActiveDownloads'; import { DownloadsHistory } from '../components/DownloadsHistory'; export function DownloadScreen() { + const { isDownloadFeatureAvailable } = useFeatureAvailable(); + + if (isDownloadFeatureAvailable) + return ( +
+ + + + +
+ ); + return ( -
- - - - +
+

+ Downloads feature is not available for MacOS. +

); } diff --git a/src/screens/MyListScreen.tsx b/src/screens/MyListScreen.tsx index e037f76..dad64e5 100644 --- a/src/screens/MyListScreen.tsx +++ b/src/screens/MyListScreen.tsx @@ -19,7 +19,7 @@ export function MyListScreen() { const { data, error, isLoading } = useQuery({ queryKey: [mode === 'manga' ? 'read-list' : 'watch-list', mode], - queryFn: () => getMyList({ url: mode === 'manga' ? 'readlist' : '/watchlist' }), + queryFn: () => getMyList({ url: mode === 'manga' ? '/readlist' : '/watchlist' }), }); if (error) return ; diff --git a/src/screens/inbuiltPlayerScreen.tsx b/src/screens/inbuiltPlayerScreen.tsx index cd67ef5..24f5489 100644 --- a/src/screens/inbuiltPlayerScreen.tsx +++ b/src/screens/inbuiltPlayerScreen.tsx @@ -23,6 +23,7 @@ import { useDownloadVideo } from 'src/hooks/useDownloadVideo'; import { useGetAnimeDetails } from 'src/hooks/useGetAnimeDetails'; import { useGetAnimeEpPagination } from 'src/hooks/useGetAnimeEpPagination'; import { useGetAnimeStream } from 'src/hooks/useGetAnimeStream'; +import { useFeatureAvailable } from 'src/utils/fn'; import { PaginateCard } from '../components/paginateCard'; import { VideoPlayer } from '../components/video-player'; @@ -109,6 +110,8 @@ export function InbuiltPlayerScreen() { else onClose(); }, [downloadLoading]); + const { isDownloadFeatureAvailable } = useFeatureAvailable(); + const animeTitle = anime.title || anime.jp_name || anime_details?.description?.eng_name; return ( @@ -192,33 +195,37 @@ export function InbuiltPlayerScreen() { ))} -
- - - Download - - - - {qualityOptions?.map(({ id, height }) => ( - singleDownloadHandler(id)}> - {height}p - - ))} - - - - {eps_details?.ep_details?.length > 1 ? ( - - ) : null} -
+ {isDownloadFeatureAvailable ? ( +
+ + + Download + + + + {qualityOptions?.map(({ id, height }) => ( + singleDownloadHandler(id)}> + {height}p + + ))} + + + + {eps_details?.ep_details?.length > 1 ? ( + + ) : null} +
+ ) : null} ) : streamLoading ? ( Promise; openExternal: (data: any) => Promise; showItemInFolder: (data: any) => Promise; + getPlatformOS: () => Promise; } declare global { interface Window { diff --git a/src/utils/fn.ts b/src/utils/fn.ts index fe569c3..b41e0e7 100644 --- a/src/utils/fn.ts +++ b/src/utils/fn.ts @@ -1,11 +1,4 @@ -export function sleep(milliseconds) { - const date = Date.now(); - let currentDate = null; - - do { - currentDate = Date.now(); - } while (currentDate - date < milliseconds); -} +import { useEffect, useState } from 'react'; export function openFileExplorer(file_location: string) { if (!file_location || !window) return; @@ -16,3 +9,27 @@ export function openExternalUrl(url: string) { if (!url || !window) return; window?.electronAPI?.openExternal(url); } + +export async function PlatformOS(): Promise { + if (!window) return; + return await window?.electronAPI?.getPlatformOS(); +} + +export const isViteDEV = import.meta.env.DEV; +export const isVitePROD = import.meta.env.PROD; + +export function useFeatureAvailable() { + const [isDownloadFeatureAvailable, setIsDownloadFeatureAvailable] = useState(true); + + useEffect(() => { + (async () => { + const platformOS = await PlatformOS(); + + setIsDownloadFeatureAvailable(!(isVitePROD && platformOS === 'darwin')); + })(); + }, []); + + return { + isDownloadFeatureAvailable, + }; +}