feat: remove unnecessary userPreferences findOne

This commit is contained in:
Zamitto 2025-01-05 12:28:33 -03:00
parent 52f85517bf
commit 39572702a0
4 changed files with 6 additions and 14 deletions

View File

@ -13,6 +13,7 @@ import { knexClient, migrationConfig } from "./knex-client";
import { databaseDirectory } from "./constants";
import { PythonRPC } from "./services/python-rpc";
import { Aria2 } from "./services/aria2";
import { loadState } from "./main";
const { autoUpdater } = updater;
@ -86,12 +87,12 @@ app.whenReady().then(async () => {
await dataSource.initialize();
await import("./main");
const userPreferences = await userPreferencesRepository.findOne({
where: { id: 1 },
});
await loadState(userPreferences);
if (userPreferences?.language) {
i18n.changeLanguage(userPreferences.language);
}

View File

@ -12,7 +12,7 @@ import { Aria2 } from "./services/aria2";
import { Downloader } from "@shared";
import { IsNull, Not } from "typeorm";
const loadState = async (userPreferences: UserPreferences | null) => {
export const loadState = async (userPreferences: UserPreferences | null) => {
await import("./events");
Aria2.spawn();
@ -49,11 +49,3 @@ const loadState = async (userPreferences: UserPreferences | null) => {
startMainLoop();
};
userPreferencesRepository
.findOne({
where: { id: 1 },
})
.then((userPreferences) => {
loadState(userPreferences);
});

View File

@ -98,9 +98,7 @@ export function DownloadSettingsModal({
? Downloader.RealDebrid
: filteredDownloaders[0];
setSelectedDownloader(
selectedDownloader === undefined ? null : selectedDownloader
);
setSelectedDownloader(selectedDownloader ?? null);
}, [
userPreferences?.downloadsPath,
downloaders,

View File

@ -299,6 +299,7 @@ export interface UpdateProfileRequest {
profileImageUrl?: string | null;
backgroundImageUrl?: string | null;
bio?: string;
language?: string;
}
export interface DownloadSourceDownload {