Run pre-commit hooks over existing codebase

Co-Authored-By: Ben Phelps <ben@phelps.io>
This commit is contained in:
shamoon 2023-10-17 23:26:55 -07:00
parent fa50bbad9c
commit 19c25713c4
387 changed files with 4785 additions and 4109 deletions

View file

@ -1,5 +1,5 @@
import { useTranslation } from "next-i18next";
import { useCallback } from 'react';
import { useCallback } from "react";
import QueueEntry from "../../components/widgets/queue/queueEntry";
@ -8,16 +8,16 @@ import Block from "components/services/widget/block";
import useWidgetAPI from "utils/proxy/use-widget-api";
function getProgress(sizeLeft, size) {
return sizeLeft === 0 ? 100 : (1 - sizeLeft / size) * 100
return sizeLeft === 0 ? 100 : (1 - sizeLeft / size) * 100;
}
function getTitle(queueEntry, seriesData) {
let title = ''
let title = "";
const seriesTitle = seriesData.find((entry) => entry.id === queueEntry.seriesId)?.title;
if (seriesTitle) title += `${seriesTitle}: `;
const { episodeTitle } = queueEntry;
if (episodeTitle) title += episodeTitle;
if (title === '') return null;
if (title === "") return null;
return title;
}
@ -65,7 +65,7 @@ export default function Component({ service }) {
<Block label="sonarr.queued" value={t("common.number", { value: queuedData.totalRecords })} />
<Block label="sonarr.series" value={t("common.number", { value: seriesData.length })} />
</Container>
{enableQueue &&
{enableQueue &&
queueDetailsData.map((queueEntry) => (
<QueueEntry
progress={getProgress(queueEntry.sizeLeft, queueEntry.size)}
@ -74,8 +74,7 @@ export default function Component({ service }) {
activity={formatDownloadState(queueEntry.trackedDownloadState)}
key={`${queueEntry.seriesId}-${queueEntry.episodeId}`}
/>
))
}
))}
</>
);
}

View file

@ -8,55 +8,55 @@ const widget = {
mappings: {
series: {
endpoint: "series",
map: (data) => asJson(data).map((entry) => ({
title: entry.title,
id: entry.id
}))
map: (data) =>
asJson(data).map((entry) => ({
title: entry.title,
id: entry.id,
})),
},
queue: {
endpoint: "queue",
validate: [
"totalRecords"
]
validate: ["totalRecords"],
},
"wanted/missing": {
endpoint: "wanted/missing",
validate: [
"totalRecords"
]
validate: ["totalRecords"],
},
"queue/details": {
endpoint: "queue/details",
map: (data) => asJson(data).map((entry) => ({
trackedDownloadState: entry.trackedDownloadState,
trackedDownloadStatus: entry.trackedDownloadStatus,
timeLeft: entry.timeleft,
size: entry.size,
sizeLeft: entry.sizeleft,
seriesId: entry.seriesId,
episodeTitle: entry.episode?.title ?? entry.title,
episodeId: entry.episodeId ?? entry.id,
status: entry.status,
})).sort((a, b) => {
const downloadingA = a.trackedDownloadState === "downloading"
const downloadingB = b.trackedDownloadState === "downloading"
if (downloadingA && !downloadingB) {
return -1;
}
if (downloadingB && !downloadingA) {
return 1;
}
map: (data) =>
asJson(data)
.map((entry) => ({
trackedDownloadState: entry.trackedDownloadState,
trackedDownloadStatus: entry.trackedDownloadStatus,
timeLeft: entry.timeleft,
size: entry.size,
sizeLeft: entry.sizeleft,
seriesId: entry.seriesId,
episodeTitle: entry.episode?.title ?? entry.title,
episodeId: entry.episodeId ?? entry.id,
status: entry.status,
}))
.sort((a, b) => {
const downloadingA = a.trackedDownloadState === "downloading";
const downloadingB = b.trackedDownloadState === "downloading";
if (downloadingA && !downloadingB) {
return -1;
}
if (downloadingB && !downloadingA) {
return 1;
}
const percentA = a.sizeLeft / a.size;
const percentB = b.sizeLeft / b.size;
if (percentA < percentB) {
return -1;
}
if (percentA > percentB) {
return 1;
}
return 0;
})
const percentA = a.sizeLeft / a.size;
const percentB = b.sizeLeft / b.size;
if (percentA < percentB) {
return -1;
}
if (percentA > percentB) {
return 1;
}
return 0;
}),
},
calendar: {
endpoint: "calendar",