fix: lint issues

This commit is contained in:
Fredrik Burmester
2025-03-30 10:21:41 +02:00
parent f6baf490fb
commit 16b834cf71
4 changed files with 31 additions and 29 deletions

View File

@@ -113,7 +113,7 @@ export const DownloadItems: React.FC<DownloadProps> = ({
);
const progress = useMemo(() => {
if (itemIds.length == 1)
if (itemIds.length === 1)
return itemsProcesses.reduce((acc, p) => acc + p.progress, 0);
return (
((itemIds.length -
@@ -126,7 +126,7 @@ export const DownloadItems: React.FC<DownloadProps> = ({
const itemsQueued = useMemo(() => {
return (
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]);
const navigateToDownloads = () => router.push("/downloads");
@@ -230,9 +230,8 @@ export const DownloadItems: React.FC<DownloadProps> = ({
if (!url || !source) throw new Error("No url");
saveDownloadItemInfoToDiskTmp(item, source, url);
if (usingOptimizedServer) {
saveDownloadItemInfoToDiskTmp(item, source, url);
await startBackgroundDownload(url, item, source);
} else {
await startRemuxing(item, url, source);
@@ -279,7 +278,7 @@ export const DownloadItems: React.FC<DownloadProps> = ({
);
const renderButtonContent = () => {
if (processes && itemsProcesses.length > 0) {
if (processes.length > 0 && itemsProcesses.length > 0) {
return progress === 0 ? (
<Loader />
) : (
@@ -293,13 +292,17 @@ export const DownloadItems: React.FC<DownloadProps> = ({
/>
</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 = () => {
@@ -405,7 +408,7 @@ export const DownloadSingleItem: React.FC<{
<DownloadItems
size={size}
title={
item.Type == "Episode"
item.Type === "Episode"
? t("item_card.download.download_episode")
: t("item_card.download.download_movie")
}

View File

@@ -132,8 +132,8 @@ export const useRemuxHlsToMp4 = () => {
totalFrames > 0 ? Math.floor((processedFrames / totalFrames) * 100) : 0;
if (!item.Id) throw new Error("Item is undefined");
setProcesses((prev: any[]) => {
return prev.map((process: { itemId: string | undefined }) => {
setProcesses((prev: JobStatus[]) => {
return prev.map((process: JobStatus) => {
if (process.itemId === item.Id) {
return {
...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 (!item.Id) throw new Error("Item must have an Id");

View File

@@ -148,7 +148,7 @@ function useDownloadProvider() {
title: job.item.Name,
body: `${job.item.Name} is ready to be downloaded`,
data: {
url: `/downloads`,
url: "/downloads",
},
},
trigger: null,
@@ -238,7 +238,7 @@ function useDownloadProvider() {
BackGroundDownloader?.download({
id: process.id,
url: settings?.optimizedVersionsServerUrl + "download/" + process.id,
url: `${settings?.optimizedVersionsServerUrl}download/${process.id}`,
destination: `${baseDirectory}/${process.item.Id}.mp4`,
})
.begin(() => {
@@ -347,7 +347,7 @@ function useDownloadProvider() {
await saveImage(item.Id, itemImage?.uri);
const response = await axios.post(
settings?.optimizedVersionsServerUrl + "optimize-version",
`${settings?.optimizedVersionsServerUrl}optimize-version`,
{
url,
fileExtension,
@@ -447,8 +447,8 @@ function useDownloadProvider() {
};
const forEveryDocumentDirFile = async (
includeMMKV = true,
ignoreList: string[] = [],
includeMMKV: boolean,
ignoreList: string[],
callback: (file: FileInfo) => void,
) => {
const baseDirectory = FileSystem.documentDirectory;
@@ -461,7 +461,7 @@ function useDownloadProvider() {
// Exclude mmkv directory.
// Deleting this deletes all user information as well. Logout should handle this.
if (
(item == "mmkv" && !includeMMKV) ||
(item === "mmkv" && !includeMMKV) ||
ignoreList.some((i) => item.includes(i))
) {
continue;
@@ -603,10 +603,10 @@ function useDownloadProvider() {
const deleteFileByType = async (type: BaseItemDto["Type"]) => {
await Promise.all(
downloadedFiles
?.filter((file) => file.item.Type == type)
?.filter((file) => file.item.Type === type)
?.flatMap((file) => {
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.Id!));
return promises;
@@ -655,9 +655,8 @@ function useDownloadProvider() {
const downloadedItems = storage.getString("downloadedItems");
if (downloadedItems) {
return JSON.parse(downloadedItems) as DownloadedItem[];
} else {
return [];
}
return [];
} catch (error) {
console.error("Failed to retrieve downloaded items:", error);
return [];
@@ -691,7 +690,7 @@ function useDownloadProvider() {
deleteDownloadItemInfoFromDiskTmp(item.Id!);
storage.set("downloadedItems", JSON.stringify(items));
storage.set("downloadedItemSize-" + item.Id, size.toString());
storage.set(`downloadedItemSize-${item.Id}`, size.toString());
queryClient.invalidateQueries({ queryKey: ["downloadedItems"] });
refetch();
@@ -704,7 +703,7 @@ function useDownloadProvider() {
}
function getDownloadedItemSize(itemId: string): number {
const size = storage.getString("downloadedItemSize-" + itemId);
const size = storage.getString(`downloadedItemSize-${itemId}`);
return size ? Number.parseInt(size) : 0;
}

View File

@@ -105,13 +105,13 @@ export async function cancelAllJobs({ authHeader, url, deviceId }: IJobInput) {
authHeader,
url,
}).then((jobs) => {
jobs.forEach((job) => {
for (const job of jobs) {
cancelJobById({
authHeader,
url,
id: job.id,
});
});
}
});
} catch (error) {
writeToLog("ERROR", "Failed to cancel all jobs", error);