mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-26 12:21:03 +00:00
25 lines
631 B
TypeScript
25 lines
631 B
TypeScript
import { userPreferencesRepository } from "@main/repository";
|
|
import { registerEvent } from "../register-event";
|
|
|
|
import type { UserPreferences } from "@types";
|
|
import { RealDebridClient } from "@main/services/real-debrid";
|
|
|
|
const updateUserPreferences = async (
|
|
_event: Electron.IpcMainInvokeEvent,
|
|
preferences: Partial<UserPreferences>
|
|
) => {
|
|
if (preferences.realDebridApiToken) {
|
|
RealDebridClient.authorize(preferences.realDebridApiToken);
|
|
}
|
|
|
|
await userPreferencesRepository.upsert(
|
|
{
|
|
id: 1,
|
|
...preferences,
|
|
},
|
|
["id"]
|
|
);
|
|
};
|
|
|
|
registerEvent("updateUserPreferences", updateUserPreferences);
|