From ab70ff10be027731ec0270a073bd170219768805 Mon Sep 17 00:00:00 2001 From: Kelvin Date: Mon, 13 Jan 2025 23:43:34 -0300 Subject: [PATCH] running format --- src/main/services/hosters/datanodes.ts | 3 +- .../confirmation-modal/confirmation-modal.tsx | 14 ++++-- .../settings/settings-download-sources.css.ts | 6 +-- .../settings/settings-download-sources.tsx | 47 ++++++++++++------- .../src/workers/download-sources.worker.ts | 12 ++--- 5 files changed, 51 insertions(+), 31 deletions(-) diff --git a/src/main/services/hosters/datanodes.ts b/src/main/services/hosters/datanodes.ts index d77e7d51..ae144418 100644 --- a/src/main/services/hosters/datanodes.ts +++ b/src/main/services/hosters/datanodes.ts @@ -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, } ); diff --git a/src/renderer/src/components/confirmation-modal/confirmation-modal.tsx b/src/renderer/src/components/confirmation-modal/confirmation-modal.tsx index f36474f8..8aea9c72 100644 --- a/src/renderer/src/components/confirmation-modal/confirmation-modal.tsx +++ b/src/renderer/src/components/confirmation-modal/confirmation-modal.tsx @@ -11,7 +11,7 @@ export interface ConfirmationModalProps extends Omit { onConfirm: () => void; onCancel?: () => void; - buttonsIsDisabled?: boolean + buttonsIsDisabled?: boolean; } export function ConfirmationModal({ @@ -38,10 +38,18 @@ export function ConfirmationModal({

{descriptionText}

- -
diff --git a/src/renderer/src/pages/settings/settings-download-sources.css.ts b/src/renderer/src/pages/settings/settings-download-sources.css.ts index 5b383587..2856c1ea 100644 --- a/src/renderer/src/pages/settings/settings-download-sources.css.ts +++ b/src/renderer/src/pages/settings/settings-download-sources.css.ts @@ -58,6 +58,6 @@ export const navigateToCatalogueButton = style({ }); export const removeAllSourcesButton = style({ - display: 'flex', - justifyContent: 'flex-end' -}) + display: "flex", + justifyContent: "flex-end", +}); diff --git a/src/renderer/src/pages/settings/settings-download-sources.tsx b/src/renderer/src/pages/settings/settings-download-sources.tsx index 859d0e16..8b1eef40 100644 --- a/src/renderer/src/pages/settings/settings-download-sources.tsx +++ b/src/renderer/src/pages/settings/settings-download-sources.tsx @@ -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([]); @@ -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} + />

{t("download_sources_description")}

@@ -233,7 +245,6 @@ export function SettingsDownloadSources() { ))} - {!isFetchingSources && downloadSources.length >= 2 && (
+
)} diff --git a/src/renderer/src/workers/download-sources.worker.ts b/src/renderer/src/workers/download-sources.worker.ts index 9ff863a2..b129e6ae 100644 --- a/src/renderer/src/workers/download-sources.worker.ts +++ b/src/renderer/src/workers/download-sources.worker.ts @@ -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) => { }); } - 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") {