Merge branch 'master' into feature/subtitle-size-change

This commit is contained in:
Fredrik Burmester
2024-12-05 18:10:38 +01:00
committed by GitHub
17 changed files with 685 additions and 429 deletions

View File

@@ -1,6 +1,9 @@
import { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
import { atom, useAtom } from "jotai";
import { useEffect } from "react";
import {JobStatus} from "@/utils/optimize-server";
import {processesAtom} from "@/providers/DownloadProvider";
import {useSettings} from "@/utils/atoms/settings";
export interface Job {
id: string;
@@ -49,11 +52,13 @@ export const queueActions = {
export const useJobProcessor = () => {
const [queue, setQueue] = useAtom(queueAtom);
const [running, setRunning] = useAtom(runningAtom);
const [processes] = useAtom<JobStatus[]>(processesAtom);
const [settings] = useSettings();
useEffect(() => {
if (queue.length > 0 && !running) {
if (queue.length > 0 && settings && processes.length < settings?.remuxConcurrentLimit) {
console.info("Processing queue", queue);
queueActions.processJob(queue, setQueue, setRunning);
}
}, [queue, running, setQueue, setRunning]);
}, [processes, queue, running, setQueue, setRunning]);
};

View File

@@ -76,6 +76,7 @@ export type Settings = {
autoDownload: boolean;
showCustomMenuLinks: boolean;
subtitleSize: number;
remuxConcurrentLimit: 1 | 2 | 3 | 4; // TODO: Maybe let people choose their own limit? 4 seems like a safe max?
};
const loadSettings = (): Settings => {
@@ -107,6 +108,7 @@ const loadSettings = (): Settings => {
autoDownload: false,
showCustomMenuLinks: false,
subtitleSize: 60,
remuxConcurrentLimit: 1,
};
try {

View File

@@ -55,6 +55,9 @@ export const writeToLog = (level: LogLevel, message: string, data?: any) => {
storage.set("logs", JSON.stringify(recentLogs));
};
export const writeInfoLog = (message: string, data?: any) => writeToLog("INFO", message, data);
export const writeErrorLog = (message: string, data?: any) => writeToLog("ERROR", message, data);
export const readFromLog = (): LogEntry[] => {
const logs = storage.getString("logs");
return logs ? JSON.parse(logs) : [];