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":
|
||||
"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;
|
||||
onCancel?: () => void;
|
||||
|
||||
buttonsIsDisabled?: boolean
|
||||
buttonsIsDisabled?: boolean;
|
||||
}
|
||||
|
||||
export function ConfirmationModal({
|
||||
|
@ -38,10 +38,18 @@ export function ConfirmationModal({
|
|||
<p className={styles.descriptionText}>{descriptionText}</p>
|
||||
|
||||
<div className={styles.actions}>
|
||||
<Button theme="outline" disabled={buttonsIsDisabled} onClick={handleCancelClick}>
|
||||
<Button
|
||||
theme="outline"
|
||||
disabled={buttonsIsDisabled}
|
||||
onClick={handleCancelClick}
|
||||
>
|
||||
{cancelButtonLabel}
|
||||
</Button>
|
||||
<Button theme="danger" disabled={buttonsIsDisabled} onClick={onConfirm}>
|
||||
<Button
|
||||
theme="danger"
|
||||
disabled={buttonsIsDisabled}
|
||||
onClick={onConfirm}
|
||||
>
|
||||
{confirmButtonLabel}
|
||||
</Button>
|
||||
</div>
|
||||
|
|
|
@ -58,6 +58,6 @@ export const navigateToCatalogueButton = style({
|
|||
});
|
||||
|
||||
export const removeAllSourcesButton = style({
|
||||
display: 'flex',
|
||||
justifyContent: 'flex-end'
|
||||
})
|
||||
display: "flex",
|
||||
justifyContent: "flex-end",
|
||||
});
|
||||
|
|
|
@ -1,11 +1,21 @@
|
|||
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 * as styles from "./settings-download-sources.css";
|
||||
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 { useAppDispatch, useRepacks, useToast } from "@renderer/hooks";
|
||||
import { DownloadSourceStatus } from "@shared";
|
||||
|
@ -16,8 +26,10 @@ import { useNavigate } from "react-router-dom";
|
|||
import { setFilters, clearFilters } from "@renderer/features";
|
||||
|
||||
export function SettingsDownloadSources() {
|
||||
const [showConfirmationDeleteAllSourcesModal, setShowConfirmationDeleteAllSourcesModal] =
|
||||
useState(false);
|
||||
const [
|
||||
showConfirmationDeleteAllSourcesModal,
|
||||
setShowConfirmationDeleteAllSourcesModal,
|
||||
] = useState(false);
|
||||
const [showAddDownloadSourceModal, setShowAddDownloadSourceModal] =
|
||||
useState(false);
|
||||
const [downloadSources, setDownloadSources] = useState<DownloadSource[]>([]);
|
||||
|
@ -25,8 +37,7 @@ export function SettingsDownloadSources() {
|
|||
useState(false);
|
||||
const [isRemovingDownloadSource, setIsRemovingDownloadSource] =
|
||||
useState(false);
|
||||
const [isFetchingSources, setIsFetchingSources] =
|
||||
useState(true);
|
||||
const [isFetchingSources, setIsFetchingSources] = useState(true);
|
||||
|
||||
const { sourceUrl, clearSourceUrl } = useContext(settingsContext);
|
||||
|
||||
|
@ -45,9 +56,10 @@ export function SettingsDownloadSources() {
|
|||
.sortBy("createdAt")
|
||||
.then((sources) => {
|
||||
setDownloadSources(sources.reverse());
|
||||
}).finally(() => {
|
||||
setIsFetchingSources(false)
|
||||
})
|
||||
.finally(() => {
|
||||
setIsFetchingSources(false);
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -86,11 +98,11 @@ export function SettingsDownloadSources() {
|
|||
showSuccessToast(t("removed_download_sources"));
|
||||
|
||||
getDownloadSources();
|
||||
setShowConfirmationDeleteAllSourcesModal(false)
|
||||
setShowConfirmationDeleteAllSourcesModal(false);
|
||||
channel.close();
|
||||
updateRepacks();
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const handleAddDownloadSource = async () => {
|
||||
await getDownloadSources();
|
||||
|
@ -144,13 +156,13 @@ export function SettingsDownloadSources() {
|
|||
cancelButtonLabel="Não"
|
||||
confirmButtonLabel="Sim, excluir"
|
||||
descriptionText="Você ira excluir todas as fontes de dowload"
|
||||
clickOutsideToClose={false}
|
||||
clickOutsideToClose={false}
|
||||
onConfirm={handleRemoveAllDowloadSources}
|
||||
visible={showConfirmationDeleteAllSourcesModal}
|
||||
title={"Excluir todas as fontes de dowload"}
|
||||
visible={showConfirmationDeleteAllSourcesModal}
|
||||
title={"Excluir todas as fontes de dowload"}
|
||||
onClose={() => setShowConfirmationDeleteAllSourcesModal(false)}
|
||||
buttonsIsDisabled={isRemovingDownloadSource}
|
||||
/>
|
||||
buttonsIsDisabled={isRemovingDownloadSource}
|
||||
/>
|
||||
|
||||
<p>{t("download_sources_description")}</p>
|
||||
|
||||
|
@ -233,7 +245,6 @@ export function SettingsDownloadSources() {
|
|||
))}
|
||||
</ul>
|
||||
|
||||
|
||||
{!isFetchingSources && downloadSources.length >= 2 && (
|
||||
<div className={styles.removeAllSourcesButton}>
|
||||
<Button
|
||||
|
@ -244,7 +255,7 @@ export function SettingsDownloadSources() {
|
|||
>
|
||||
<XIcon />
|
||||
Remover todas as fontes de dowload
|
||||
</Button>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
|
|
|
@ -21,7 +21,7 @@ export const downloadSourceSchema = z.object({
|
|||
|
||||
type Payload =
|
||||
| ["IMPORT_DOWNLOAD_SOURCE", string]
|
||||
| ["DELETE_DOWNLOAD_SOURCE", number]
|
||||
| ["DELETE_DOWNLOAD_SOURCE", number]
|
||||
| ["VALIDATE_DOWNLOAD_SOURCE", string]
|
||||
| ["SYNC_DOWNLOAD_SOURCES", string]
|
||||
| ["DELETE_ALL_DOWNLOAD_SOURCES", string];
|
||||
|
@ -117,7 +117,7 @@ const deleteDownloadSource = async (id: number) => {
|
|||
|
||||
const deleteAllDowloadsSources = async () => {
|
||||
await db.transaction("rw", repacksTable, downloadSourcesTable, async () => {
|
||||
await repacksTable.clear()
|
||||
await repacksTable.clear();
|
||||
await downloadSourcesTable.clear();
|
||||
});
|
||||
};
|
||||
|
@ -140,12 +140,12 @@ self.onmessage = async (event: MessageEvent<Payload>) => {
|
|||
});
|
||||
}
|
||||
|
||||
if (type === 'DELETE_ALL_DOWNLOAD_SOURCES') {
|
||||
await deleteAllDowloadsSources()
|
||||
if (type === "DELETE_ALL_DOWNLOAD_SOURCES") {
|
||||
await deleteAllDowloadsSources();
|
||||
|
||||
const channel = new BroadcastChannel(`download_sources:delete_all:${data}`);
|
||||
|
||||
channel.postMessage(true)
|
||||
|
||||
channel.postMessage(true);
|
||||
}
|
||||
|
||||
if (type === "DELETE_DOWNLOAD_SOURCE") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue