mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-15 23:59:08 +00:00
wip
This commit is contained in:
@@ -13,12 +13,15 @@ import {
|
||||
BaseItemDto,
|
||||
MediaSourceInfo,
|
||||
} from "@jellyfin/sdk/lib/generated-client/models";
|
||||
import {
|
||||
checkForExistingDownloads,
|
||||
completeHandler,
|
||||
download,
|
||||
setConfig,
|
||||
} from "@kesha-antonov/react-native-background-downloader";
|
||||
// import {
|
||||
// checkForExistingDownloads,
|
||||
// completeHandler,
|
||||
// download,
|
||||
// setConfig,
|
||||
// } from "@kesha-antonov/react-native-background-downloader";
|
||||
const BackGroundDownloader = !Platform.isTV
|
||||
? require("@kesha-antonov/react-native-background-downloader")
|
||||
: null;
|
||||
import MMKV from "react-native-mmkv";
|
||||
import {
|
||||
focusManager,
|
||||
@@ -42,13 +45,14 @@ import React, {
|
||||
import { AppState, AppStateStatus, Platform } from "react-native";
|
||||
import { toast } from "sonner-native";
|
||||
import { apiAtom } from "./JellyfinProvider";
|
||||
import * as Notifications from "expo-notifications";
|
||||
// import * as Notifications from "expo-notifications";
|
||||
const Notifications = !Platform.isTV ? require("expo-notifications") : null;
|
||||
import { getItemImage } from "@/utils/getItemImage";
|
||||
import useImageStorage from "@/hooks/useImageStorage";
|
||||
import { storage } from "@/utils/mmkv";
|
||||
import useDownloadHelper from "@/utils/download";
|
||||
import { FileInfo } from "expo-file-system";
|
||||
import * as Haptics from "expo-haptics";
|
||||
import * as Haptics from "@/packages/expo-haptics";
|
||||
import * as Application from "expo-application";
|
||||
|
||||
export type DownloadedItem = {
|
||||
@@ -67,6 +71,7 @@ const DownloadContext = createContext<ReturnType<
|
||||
> | null>(null);
|
||||
|
||||
function useDownloadProvider() {
|
||||
if (Platform.isTV) return;
|
||||
const queryClient = useQueryClient();
|
||||
const [settings] = useSettings();
|
||||
const router = useRouter();
|
||||
@@ -170,7 +175,7 @@ function useDownloadProvider() {
|
||||
useEffect(() => {
|
||||
const checkIfShouldStartDownload = async () => {
|
||||
if (processes.length === 0) return;
|
||||
await checkForExistingDownloads();
|
||||
await BackGroundDownloader.checkForExistingDownloads();
|
||||
};
|
||||
|
||||
checkIfShouldStartDownload();
|
||||
@@ -214,7 +219,7 @@ function useDownloadProvider() {
|
||||
)
|
||||
);
|
||||
|
||||
setConfig({
|
||||
BackGroundDownloader.setConfig({
|
||||
isLogsEnabled: true,
|
||||
progressInterval: 500,
|
||||
headers: {
|
||||
@@ -234,7 +239,7 @@ function useDownloadProvider() {
|
||||
|
||||
const baseDirectory = FileSystem.documentDirectory;
|
||||
|
||||
download({
|
||||
BackGroundDownloader.download({
|
||||
id: process.id,
|
||||
url: settings?.optimizedVersionsServerUrl + "download/" + process.id,
|
||||
destination: `${baseDirectory}/${process.item.Id}.mp4`,
|
||||
@@ -284,7 +289,7 @@ function useDownloadProvider() {
|
||||
},
|
||||
});
|
||||
setTimeout(() => {
|
||||
completeHandler(process.id);
|
||||
BackGroundDownloader.completeHandler(process.id);
|
||||
removeProcess(process.id);
|
||||
}, 1000);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user