mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
running format
This commit is contained in:
parent
6a429f9f39
commit
ab70ff10be
5 changed files with 51 additions and 31 deletions
|
@ -33,7 +33,8 @@ export class DatanodesApi {
|
||||||
"User-Agent":
|
"User-Agent":
|
||||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36",
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36",
|
||||||
},
|
},
|
||||||
maxRedirects: 0, validateStatus: (status: number) => status === 302 || status < 400,
|
maxRedirects: 0,
|
||||||
|
validateStatus: (status: number) => status === 302 || status < 400,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ export interface ConfirmationModalProps extends Omit<ModalProps, "children"> {
|
||||||
onConfirm: () => void;
|
onConfirm: () => void;
|
||||||
onCancel?: () => void;
|
onCancel?: () => void;
|
||||||
|
|
||||||
buttonsIsDisabled?: boolean
|
buttonsIsDisabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ConfirmationModal({
|
export function ConfirmationModal({
|
||||||
|
@ -38,10 +38,18 @@ export function ConfirmationModal({
|
||||||
<p className={styles.descriptionText}>{descriptionText}</p>
|
<p className={styles.descriptionText}>{descriptionText}</p>
|
||||||
|
|
||||||
<div className={styles.actions}>
|
<div className={styles.actions}>
|
||||||
<Button theme="outline" disabled={buttonsIsDisabled} onClick={handleCancelClick}>
|
<Button
|
||||||
|
theme="outline"
|
||||||
|
disabled={buttonsIsDisabled}
|
||||||
|
onClick={handleCancelClick}
|
||||||
|
>
|
||||||
{cancelButtonLabel}
|
{cancelButtonLabel}
|
||||||
</Button>
|
</Button>
|
||||||
<Button theme="danger" disabled={buttonsIsDisabled} onClick={onConfirm}>
|
<Button
|
||||||
|
theme="danger"
|
||||||
|
disabled={buttonsIsDisabled}
|
||||||
|
onClick={onConfirm}
|
||||||
|
>
|
||||||
{confirmButtonLabel}
|
{confirmButtonLabel}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -58,6 +58,6 @@ export const navigateToCatalogueButton = style({
|
||||||
});
|
});
|
||||||
|
|
||||||
export const removeAllSourcesButton = style({
|
export const removeAllSourcesButton = style({
|
||||||
display: 'flex',
|
display: "flex",
|
||||||
justifyContent: 'flex-end'
|
justifyContent: "flex-end",
|
||||||
})
|
});
|
||||||
|
|
|
@ -1,11 +1,21 @@
|
||||||
import { useContext, useEffect, useState } from "react";
|
import { useContext, useEffect, useState } from "react";
|
||||||
|
|
||||||
import { TextField, Button, Badge, ConfirmationModal } from "@renderer/components";
|
import {
|
||||||
|
TextField,
|
||||||
|
Button,
|
||||||
|
Badge,
|
||||||
|
ConfirmationModal,
|
||||||
|
} from "@renderer/components";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import * as styles from "./settings-download-sources.css";
|
import * as styles from "./settings-download-sources.css";
|
||||||
import type { DownloadSource } from "@types";
|
import type { DownloadSource } from "@types";
|
||||||
import { NoEntryIcon, PlusCircleIcon, SyncIcon, XIcon } from "@primer/octicons-react";
|
import {
|
||||||
|
NoEntryIcon,
|
||||||
|
PlusCircleIcon,
|
||||||
|
SyncIcon,
|
||||||
|
XIcon,
|
||||||
|
} from "@primer/octicons-react";
|
||||||
import { AddDownloadSourceModal } from "./add-download-source-modal";
|
import { AddDownloadSourceModal } from "./add-download-source-modal";
|
||||||
import { useAppDispatch, useRepacks, useToast } from "@renderer/hooks";
|
import { useAppDispatch, useRepacks, useToast } from "@renderer/hooks";
|
||||||
import { DownloadSourceStatus } from "@shared";
|
import { DownloadSourceStatus } from "@shared";
|
||||||
|
@ -16,8 +26,10 @@ import { useNavigate } from "react-router-dom";
|
||||||
import { setFilters, clearFilters } from "@renderer/features";
|
import { setFilters, clearFilters } from "@renderer/features";
|
||||||
|
|
||||||
export function SettingsDownloadSources() {
|
export function SettingsDownloadSources() {
|
||||||
const [showConfirmationDeleteAllSourcesModal, setShowConfirmationDeleteAllSourcesModal] =
|
const [
|
||||||
useState(false);
|
showConfirmationDeleteAllSourcesModal,
|
||||||
|
setShowConfirmationDeleteAllSourcesModal,
|
||||||
|
] = useState(false);
|
||||||
const [showAddDownloadSourceModal, setShowAddDownloadSourceModal] =
|
const [showAddDownloadSourceModal, setShowAddDownloadSourceModal] =
|
||||||
useState(false);
|
useState(false);
|
||||||
const [downloadSources, setDownloadSources] = useState<DownloadSource[]>([]);
|
const [downloadSources, setDownloadSources] = useState<DownloadSource[]>([]);
|
||||||
|
@ -25,8 +37,7 @@ export function SettingsDownloadSources() {
|
||||||
useState(false);
|
useState(false);
|
||||||
const [isRemovingDownloadSource, setIsRemovingDownloadSource] =
|
const [isRemovingDownloadSource, setIsRemovingDownloadSource] =
|
||||||
useState(false);
|
useState(false);
|
||||||
const [isFetchingSources, setIsFetchingSources] =
|
const [isFetchingSources, setIsFetchingSources] = useState(true);
|
||||||
useState(true);
|
|
||||||
|
|
||||||
const { sourceUrl, clearSourceUrl } = useContext(settingsContext);
|
const { sourceUrl, clearSourceUrl } = useContext(settingsContext);
|
||||||
|
|
||||||
|
@ -45,9 +56,10 @@ export function SettingsDownloadSources() {
|
||||||
.sortBy("createdAt")
|
.sortBy("createdAt")
|
||||||
.then((sources) => {
|
.then((sources) => {
|
||||||
setDownloadSources(sources.reverse());
|
setDownloadSources(sources.reverse());
|
||||||
}).finally(() => {
|
|
||||||
setIsFetchingSources(false)
|
|
||||||
})
|
})
|
||||||
|
.finally(() => {
|
||||||
|
setIsFetchingSources(false);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -86,11 +98,11 @@ export function SettingsDownloadSources() {
|
||||||
showSuccessToast(t("removed_download_sources"));
|
showSuccessToast(t("removed_download_sources"));
|
||||||
|
|
||||||
getDownloadSources();
|
getDownloadSources();
|
||||||
setShowConfirmationDeleteAllSourcesModal(false)
|
setShowConfirmationDeleteAllSourcesModal(false);
|
||||||
channel.close();
|
channel.close();
|
||||||
updateRepacks();
|
updateRepacks();
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
const handleAddDownloadSource = async () => {
|
const handleAddDownloadSource = async () => {
|
||||||
await getDownloadSources();
|
await getDownloadSources();
|
||||||
|
@ -144,13 +156,13 @@ export function SettingsDownloadSources() {
|
||||||
cancelButtonLabel="Não"
|
cancelButtonLabel="Não"
|
||||||
confirmButtonLabel="Sim, excluir"
|
confirmButtonLabel="Sim, excluir"
|
||||||
descriptionText="Você ira excluir todas as fontes de dowload"
|
descriptionText="Você ira excluir todas as fontes de dowload"
|
||||||
clickOutsideToClose={false}
|
clickOutsideToClose={false}
|
||||||
onConfirm={handleRemoveAllDowloadSources}
|
onConfirm={handleRemoveAllDowloadSources}
|
||||||
visible={showConfirmationDeleteAllSourcesModal}
|
visible={showConfirmationDeleteAllSourcesModal}
|
||||||
title={"Excluir todas as fontes de dowload"}
|
title={"Excluir todas as fontes de dowload"}
|
||||||
onClose={() => setShowConfirmationDeleteAllSourcesModal(false)}
|
onClose={() => setShowConfirmationDeleteAllSourcesModal(false)}
|
||||||
buttonsIsDisabled={isRemovingDownloadSource}
|
buttonsIsDisabled={isRemovingDownloadSource}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<p>{t("download_sources_description")}</p>
|
<p>{t("download_sources_description")}</p>
|
||||||
|
|
||||||
|
@ -233,7 +245,6 @@ export function SettingsDownloadSources() {
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
{!isFetchingSources && downloadSources.length >= 2 && (
|
{!isFetchingSources && downloadSources.length >= 2 && (
|
||||||
<div className={styles.removeAllSourcesButton}>
|
<div className={styles.removeAllSourcesButton}>
|
||||||
<Button
|
<Button
|
||||||
|
@ -244,7 +255,7 @@ export function SettingsDownloadSources() {
|
||||||
>
|
>
|
||||||
<XIcon />
|
<XIcon />
|
||||||
Remover todas as fontes de dowload
|
Remover todas as fontes de dowload
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -21,7 +21,7 @@ export const downloadSourceSchema = z.object({
|
||||||
|
|
||||||
type Payload =
|
type Payload =
|
||||||
| ["IMPORT_DOWNLOAD_SOURCE", string]
|
| ["IMPORT_DOWNLOAD_SOURCE", string]
|
||||||
| ["DELETE_DOWNLOAD_SOURCE", number]
|
| ["DELETE_DOWNLOAD_SOURCE", number]
|
||||||
| ["VALIDATE_DOWNLOAD_SOURCE", string]
|
| ["VALIDATE_DOWNLOAD_SOURCE", string]
|
||||||
| ["SYNC_DOWNLOAD_SOURCES", string]
|
| ["SYNC_DOWNLOAD_SOURCES", string]
|
||||||
| ["DELETE_ALL_DOWNLOAD_SOURCES", string];
|
| ["DELETE_ALL_DOWNLOAD_SOURCES", string];
|
||||||
|
@ -117,7 +117,7 @@ const deleteDownloadSource = async (id: number) => {
|
||||||
|
|
||||||
const deleteAllDowloadsSources = async () => {
|
const deleteAllDowloadsSources = async () => {
|
||||||
await db.transaction("rw", repacksTable, downloadSourcesTable, async () => {
|
await db.transaction("rw", repacksTable, downloadSourcesTable, async () => {
|
||||||
await repacksTable.clear()
|
await repacksTable.clear();
|
||||||
await downloadSourcesTable.clear();
|
await downloadSourcesTable.clear();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -140,12 +140,12 @@ self.onmessage = async (event: MessageEvent<Payload>) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'DELETE_ALL_DOWNLOAD_SOURCES') {
|
if (type === "DELETE_ALL_DOWNLOAD_SOURCES") {
|
||||||
await deleteAllDowloadsSources()
|
await deleteAllDowloadsSources();
|
||||||
|
|
||||||
const channel = new BroadcastChannel(`download_sources:delete_all:${data}`);
|
const channel = new BroadcastChannel(`download_sources:delete_all:${data}`);
|
||||||
|
|
||||||
channel.postMessage(true)
|
channel.postMessage(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === "DELETE_DOWNLOAD_SOURCE") {
|
if (type === "DELETE_DOWNLOAD_SOURCE") {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue