mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-09 03:37:45 +03:00
feat: save torbox token
This commit is contained in:
parent
e3b9b16387
commit
d8e322e022
@ -15,6 +15,12 @@ const getUserPreferences = async () =>
|
||||
);
|
||||
}
|
||||
|
||||
if (userPreferences?.torBoxApiToken) {
|
||||
userPreferences.torBoxApiToken = Crypto.decrypt(
|
||||
userPreferences.torBoxApiToken
|
||||
);
|
||||
}
|
||||
|
||||
return userPreferences;
|
||||
});
|
||||
|
||||
|
@ -30,6 +30,10 @@ const updateUserPreferences = async (
|
||||
);
|
||||
}
|
||||
|
||||
if (preferences.torBoxApiToken) {
|
||||
preferences.torBoxApiToken = Crypto.encrypt(preferences.torBoxApiToken);
|
||||
}
|
||||
|
||||
if (!preferences.downloadsPath) {
|
||||
preferences.downloadsPath = null;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import {
|
||||
} from "./level";
|
||||
import { Auth, User, type UserPreferences } from "@types";
|
||||
import { knexClient } from "./knex-client";
|
||||
import { TorBoxClient } from "./services/download/torbox";
|
||||
|
||||
export const loadState = async () => {
|
||||
const userPreferences = await migrateFromSqlite().then(async () => {
|
||||
@ -42,6 +43,10 @@ export const loadState = async () => {
|
||||
);
|
||||
}
|
||||
|
||||
if (userPreferences?.torBoxApiToken) {
|
||||
TorBoxClient.authorize(Crypto.decrypt(userPreferences.torBoxApiToken));
|
||||
}
|
||||
|
||||
Ludusavi.addManifestToLudusaviConfig();
|
||||
|
||||
HydraApi.setupApi().then(() => {
|
||||
|
@ -31,6 +31,7 @@ import {
|
||||
} from "@primer/octicons-react";
|
||||
|
||||
import torBoxLogo from "@renderer/assets/icons/torbox.webp";
|
||||
import { SPACING_UNIT, vars } from "@renderer/theme.css";
|
||||
|
||||
export interface DownloadGroupProps {
|
||||
library: LibraryGame[];
|
||||
@ -237,12 +238,16 @@ export function DownloadGroup({
|
||||
];
|
||||
}
|
||||
|
||||
const isResumeDisabled =
|
||||
(download?.downloader === Downloader.RealDebrid &&
|
||||
!userPreferences?.realDebridApiToken) ||
|
||||
(download?.downloader === Downloader.TorBox &&
|
||||
!userPreferences?.torBoxApiToken);
|
||||
|
||||
return [
|
||||
{
|
||||
label: t("resume"),
|
||||
disabled:
|
||||
download?.downloader === Downloader.RealDebrid &&
|
||||
!userPreferences?.realDebridApiToken,
|
||||
disabled: isResumeDisabled,
|
||||
onClick: () => {
|
||||
resumeDownload(game.shop, game.objectId);
|
||||
},
|
||||
|
@ -88,6 +88,8 @@ export function DownloadSettingsModal({
|
||||
const filteredDownloaders = downloaders.filter((downloader) => {
|
||||
if (downloader === Downloader.RealDebrid)
|
||||
return userPreferences?.realDebridApiToken;
|
||||
if (downloader === Downloader.TorBox)
|
||||
return userPreferences?.torBoxApiToken;
|
||||
return true;
|
||||
});
|
||||
|
||||
|
@ -71,6 +71,7 @@ export function SettingsDebrid() {
|
||||
|
||||
updateUserPreferences({
|
||||
realDebridApiToken: form.useRealDebrid ? form.realDebridApiToken : null,
|
||||
torBoxApiToken: form.useTorBox ? form.torBoxApiToken : null,
|
||||
});
|
||||
} catch (err) {
|
||||
showErrorToast(t("real_debrid_invalid_token"));
|
||||
|
@ -55,22 +55,6 @@ export interface GameRunning {
|
||||
sessionDurationInMillis: number;
|
||||
}
|
||||
|
||||
export interface UserPreferences {
|
||||
downloadsPath: string | null;
|
||||
language: string;
|
||||
downloadNotificationsEnabled: boolean;
|
||||
repackUpdatesNotificationsEnabled: boolean;
|
||||
achievementNotificationsEnabled: boolean;
|
||||
realDebridApiToken: string | null;
|
||||
torBoxApiToken: string | null;
|
||||
preferQuitInsteadOfHiding: boolean;
|
||||
runAtStartup: boolean;
|
||||
startMinimized: boolean;
|
||||
disableNsfwAlert: boolean;
|
||||
seedAfterDownloadComplete: boolean;
|
||||
showHiddenAchievementsDescription: boolean;
|
||||
}
|
||||
|
||||
export interface Steam250Game {
|
||||
title: string;
|
||||
objectId: string;
|
||||
|
@ -69,6 +69,7 @@ export interface UserPreferences {
|
||||
downloadsPath?: string | null;
|
||||
language?: string;
|
||||
realDebridApiToken?: string | null;
|
||||
torBoxApiToken?: string | null;
|
||||
preferQuitInsteadOfHiding?: boolean;
|
||||
runAtStartup?: boolean;
|
||||
startMinimized?: boolean;
|
||||
|
Loading…
Reference in New Issue
Block a user