mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-04-21 16:24:41 +01:00
fix: lint issues
This commit is contained in:
@@ -113,7 +113,7 @@ export const DownloadItems: React.FC<DownloadProps> = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const progress = useMemo(() => {
|
const progress = useMemo(() => {
|
||||||
if (itemIds.length == 1)
|
if (itemIds.length === 1)
|
||||||
return itemsProcesses.reduce((acc, p) => acc + p.progress, 0);
|
return itemsProcesses.reduce((acc, p) => acc + p.progress, 0);
|
||||||
return (
|
return (
|
||||||
((itemIds.length -
|
((itemIds.length -
|
||||||
@@ -126,7 +126,7 @@ export const DownloadItems: React.FC<DownloadProps> = ({
|
|||||||
const itemsQueued = useMemo(() => {
|
const itemsQueued = useMemo(() => {
|
||||||
return (
|
return (
|
||||||
itemsNotDownloaded.length > 0 &&
|
itemsNotDownloaded.length > 0 &&
|
||||||
itemsNotDownloaded.every((p) => queue.some((q) => p.Id == q.item.Id))
|
itemsNotDownloaded.every((p) => queue.some((q) => p.Id === q.item.Id))
|
||||||
);
|
);
|
||||||
}, [queue, itemsNotDownloaded]);
|
}, [queue, itemsNotDownloaded]);
|
||||||
const navigateToDownloads = () => router.push("/downloads");
|
const navigateToDownloads = () => router.push("/downloads");
|
||||||
@@ -230,9 +230,8 @@ export const DownloadItems: React.FC<DownloadProps> = ({
|
|||||||
|
|
||||||
if (!url || !source) throw new Error("No url");
|
if (!url || !source) throw new Error("No url");
|
||||||
|
|
||||||
saveDownloadItemInfoToDiskTmp(item, source, url);
|
|
||||||
|
|
||||||
if (usingOptimizedServer) {
|
if (usingOptimizedServer) {
|
||||||
|
saveDownloadItemInfoToDiskTmp(item, source, url);
|
||||||
await startBackgroundDownload(url, item, source);
|
await startBackgroundDownload(url, item, source);
|
||||||
} else {
|
} else {
|
||||||
await startRemuxing(item, url, source);
|
await startRemuxing(item, url, source);
|
||||||
@@ -279,7 +278,7 @@ export const DownloadItems: React.FC<DownloadProps> = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const renderButtonContent = () => {
|
const renderButtonContent = () => {
|
||||||
if (processes && itemsProcesses.length > 0) {
|
if (processes.length > 0 && itemsProcesses.length > 0) {
|
||||||
return progress === 0 ? (
|
return progress === 0 ? (
|
||||||
<Loader />
|
<Loader />
|
||||||
) : (
|
) : (
|
||||||
@@ -293,13 +292,17 @@ export const DownloadItems: React.FC<DownloadProps> = ({
|
|||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
} else if (itemsQueued) {
|
|
||||||
return <Ionicons name='hourglass' size={24} color='white' />;
|
|
||||||
} else if (allItemsDownloaded) {
|
|
||||||
return <DownloadedIconComponent />;
|
|
||||||
} else {
|
|
||||||
return <MissingDownloadIconComponent />;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (itemsQueued) {
|
||||||
|
return <Ionicons name='hourglass' size={24} color='white' />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allItemsDownloaded) {
|
||||||
|
return <DownloadedIconComponent />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <MissingDownloadIconComponent />;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onButtonPress = () => {
|
const onButtonPress = () => {
|
||||||
@@ -405,7 +408,7 @@ export const DownloadSingleItem: React.FC<{
|
|||||||
<DownloadItems
|
<DownloadItems
|
||||||
size={size}
|
size={size}
|
||||||
title={
|
title={
|
||||||
item.Type == "Episode"
|
item.Type === "Episode"
|
||||||
? t("item_card.download.download_episode")
|
? t("item_card.download.download_episode")
|
||||||
: t("item_card.download.download_movie")
|
: t("item_card.download.download_movie")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,8 +132,8 @@ export const useRemuxHlsToMp4 = () => {
|
|||||||
totalFrames > 0 ? Math.floor((processedFrames / totalFrames) * 100) : 0;
|
totalFrames > 0 ? Math.floor((processedFrames / totalFrames) * 100) : 0;
|
||||||
|
|
||||||
if (!item.Id) throw new Error("Item is undefined");
|
if (!item.Id) throw new Error("Item is undefined");
|
||||||
setProcesses((prev: any[]) => {
|
setProcesses((prev: JobStatus[]) => {
|
||||||
return prev.map((process: { itemId: string | undefined }) => {
|
return prev.map((process: JobStatus) => {
|
||||||
if (process.itemId === item.Id) {
|
if (process.itemId === item.Id) {
|
||||||
return {
|
return {
|
||||||
...process,
|
...process,
|
||||||
@@ -160,7 +160,7 @@ export const useRemuxHlsToMp4 = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const output = APP_CACHE_DOWNLOAD_DIRECTORY + `${item.Id}.mp4`;
|
const output = `${APP_CACHE_DOWNLOAD_DIRECTORY}${item.Id}.mp4`;
|
||||||
|
|
||||||
if (!api) throw new Error("API is not defined");
|
if (!api) throw new Error("API is not defined");
|
||||||
if (!item.Id) throw new Error("Item must have an Id");
|
if (!item.Id) throw new Error("Item must have an Id");
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ function useDownloadProvider() {
|
|||||||
title: job.item.Name,
|
title: job.item.Name,
|
||||||
body: `${job.item.Name} is ready to be downloaded`,
|
body: `${job.item.Name} is ready to be downloaded`,
|
||||||
data: {
|
data: {
|
||||||
url: `/downloads`,
|
url: "/downloads",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
trigger: null,
|
trigger: null,
|
||||||
@@ -238,7 +238,7 @@ function useDownloadProvider() {
|
|||||||
|
|
||||||
BackGroundDownloader?.download({
|
BackGroundDownloader?.download({
|
||||||
id: process.id,
|
id: process.id,
|
||||||
url: settings?.optimizedVersionsServerUrl + "download/" + process.id,
|
url: `${settings?.optimizedVersionsServerUrl}download/${process.id}`,
|
||||||
destination: `${baseDirectory}/${process.item.Id}.mp4`,
|
destination: `${baseDirectory}/${process.item.Id}.mp4`,
|
||||||
})
|
})
|
||||||
.begin(() => {
|
.begin(() => {
|
||||||
@@ -347,7 +347,7 @@ function useDownloadProvider() {
|
|||||||
await saveImage(item.Id, itemImage?.uri);
|
await saveImage(item.Id, itemImage?.uri);
|
||||||
|
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
settings?.optimizedVersionsServerUrl + "optimize-version",
|
`${settings?.optimizedVersionsServerUrl}optimize-version`,
|
||||||
{
|
{
|
||||||
url,
|
url,
|
||||||
fileExtension,
|
fileExtension,
|
||||||
@@ -447,8 +447,8 @@ function useDownloadProvider() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const forEveryDocumentDirFile = async (
|
const forEveryDocumentDirFile = async (
|
||||||
includeMMKV = true,
|
includeMMKV: boolean,
|
||||||
ignoreList: string[] = [],
|
ignoreList: string[],
|
||||||
callback: (file: FileInfo) => void,
|
callback: (file: FileInfo) => void,
|
||||||
) => {
|
) => {
|
||||||
const baseDirectory = FileSystem.documentDirectory;
|
const baseDirectory = FileSystem.documentDirectory;
|
||||||
@@ -461,7 +461,7 @@ function useDownloadProvider() {
|
|||||||
// Exclude mmkv directory.
|
// Exclude mmkv directory.
|
||||||
// Deleting this deletes all user information as well. Logout should handle this.
|
// Deleting this deletes all user information as well. Logout should handle this.
|
||||||
if (
|
if (
|
||||||
(item == "mmkv" && !includeMMKV) ||
|
(item === "mmkv" && !includeMMKV) ||
|
||||||
ignoreList.some((i) => item.includes(i))
|
ignoreList.some((i) => item.includes(i))
|
||||||
) {
|
) {
|
||||||
continue;
|
continue;
|
||||||
@@ -603,10 +603,10 @@ function useDownloadProvider() {
|
|||||||
const deleteFileByType = async (type: BaseItemDto["Type"]) => {
|
const deleteFileByType = async (type: BaseItemDto["Type"]) => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
downloadedFiles
|
downloadedFiles
|
||||||
?.filter((file) => file.item.Type == type)
|
?.filter((file) => file.item.Type === type)
|
||||||
?.flatMap((file) => {
|
?.flatMap((file) => {
|
||||||
const promises = [];
|
const promises = [];
|
||||||
if (type == "Episode" && file.item.SeriesId)
|
if (type === "Episode" && file.item.SeriesId)
|
||||||
promises.push(deleteFile(file.item.SeriesId));
|
promises.push(deleteFile(file.item.SeriesId));
|
||||||
promises.push(deleteFile(file.item.Id!));
|
promises.push(deleteFile(file.item.Id!));
|
||||||
return promises;
|
return promises;
|
||||||
@@ -655,9 +655,8 @@ function useDownloadProvider() {
|
|||||||
const downloadedItems = storage.getString("downloadedItems");
|
const downloadedItems = storage.getString("downloadedItems");
|
||||||
if (downloadedItems) {
|
if (downloadedItems) {
|
||||||
return JSON.parse(downloadedItems) as DownloadedItem[];
|
return JSON.parse(downloadedItems) as DownloadedItem[];
|
||||||
} else {
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
return [];
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to retrieve downloaded items:", error);
|
console.error("Failed to retrieve downloaded items:", error);
|
||||||
return [];
|
return [];
|
||||||
@@ -691,7 +690,7 @@ function useDownloadProvider() {
|
|||||||
deleteDownloadItemInfoFromDiskTmp(item.Id!);
|
deleteDownloadItemInfoFromDiskTmp(item.Id!);
|
||||||
|
|
||||||
storage.set("downloadedItems", JSON.stringify(items));
|
storage.set("downloadedItems", JSON.stringify(items));
|
||||||
storage.set("downloadedItemSize-" + item.Id, size.toString());
|
storage.set(`downloadedItemSize-${item.Id}`, size.toString());
|
||||||
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["downloadedItems"] });
|
queryClient.invalidateQueries({ queryKey: ["downloadedItems"] });
|
||||||
refetch();
|
refetch();
|
||||||
@@ -704,7 +703,7 @@ function useDownloadProvider() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDownloadedItemSize(itemId: string): number {
|
function getDownloadedItemSize(itemId: string): number {
|
||||||
const size = storage.getString("downloadedItemSize-" + itemId);
|
const size = storage.getString(`downloadedItemSize-${itemId}`);
|
||||||
return size ? Number.parseInt(size) : 0;
|
return size ? Number.parseInt(size) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,13 +105,13 @@ export async function cancelAllJobs({ authHeader, url, deviceId }: IJobInput) {
|
|||||||
authHeader,
|
authHeader,
|
||||||
url,
|
url,
|
||||||
}).then((jobs) => {
|
}).then((jobs) => {
|
||||||
jobs.forEach((job) => {
|
for (const job of jobs) {
|
||||||
cancelJobById({
|
cancelJobById({
|
||||||
authHeader,
|
authHeader,
|
||||||
url,
|
url,
|
||||||
id: job.id,
|
id: job.id,
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
writeToLog("ERROR", "Failed to cancel all jobs", error);
|
writeToLog("ERROR", "Failed to cancel all jobs", error);
|
||||||
|
|||||||
Reference in New Issue
Block a user