From 0b68ddda78f6a231324b7b7d2bb4156e846446ee Mon Sep 17 00:00:00 2001
From: Chubby Granny Chaser
Date: Tue, 4 Jun 2024 11:28:11 +0100
Subject: [PATCH] feat: adding resync button
---
src/locales/en/translation.json | 7 ++-
src/locales/pt/translation.json | 7 ++-
src/main/entity/download-source.entity.ts | 2 +-
.../settings/settings-download-sources.css.ts | 5 +-
.../settings/settings-download-sources.tsx | 46 +++++++++++++------
5 files changed, 47 insertions(+), 20 deletions(-)
diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json
index 7d36cba2..d5c1456f 100644
--- a/src/locales/en/translation.json
+++ b/src/locales/en/translation.json
@@ -167,7 +167,12 @@
"download_options_one": "{{countFormatted}} download option",
"download_options_other": "{{countFormatted}} download options",
"download_source_url": "Download source URL",
- "add_download_source_description": "Insert the URL containing the JSON file"
+ "add_download_source_description": "Insert the URL containing the JSON file",
+ "download_source_up_to_date": "Up-to-date",
+ "download_source_errored": "Errored",
+ "resync_download_sources": "Resync",
+ "removed_download_source": "Download source removed",
+ "added_download_source": "Added download source"
},
"notifications": {
"download_complete": "Download complete",
diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json
index 1ec065e6..b991765f 100644
--- a/src/locales/pt/translation.json
+++ b/src/locales/pt/translation.json
@@ -164,7 +164,12 @@
"download_options_one": "{{countFormatted}} opcão de download",
"download_options_other": "{{countFormatted}} opções de download",
"download_source_url": "URL da biblioteca",
- "add_download_source_description": "Insira a URL contendo o arquivo JSON"
+ "add_download_source_description": "Insira a URL contendo o arquivo JSON",
+ "download_source_up_to_date": "Atualizado",
+ "download_source_errored": "Falhou",
+ "resync_download_sources": "Resincronizar",
+ "removed_download_source": "Biblioteca removida",
+ "added_download_source": "Biblioteca adicionada"
},
"notifications": {
"download_complete": "Download concluído",
diff --git a/src/main/entity/download-source.entity.ts b/src/main/entity/download-source.entity.ts
index 98e1f538..3020f4ac 100644
--- a/src/main/entity/download-source.entity.ts
+++ b/src/main/entity/download-source.entity.ts
@@ -23,7 +23,7 @@ export class DownloadSource {
@Column("text", { nullable: true })
etag: string | null;
- @Column("text", { default: "online" })
+ @Column("text", { default: DownloadSourceStatus.UpToDate })
status: DownloadSourceStatus;
@OneToMany(() => Repack, (repack) => repack.downloadSource, { cascade: true })
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 f7b1b481..239c1be3 100644
--- a/src/renderer/src/pages/settings/settings-download-sources.css.ts
+++ b/src/renderer/src/pages/settings/settings-download-sources.css.ts
@@ -8,6 +8,7 @@ export const downloadSourceField = style({
export const downloadSources = style({
padding: "0",
+ margin: "0",
gap: `${SPACING_UNIT * 2}px`,
display: "flex",
flexDirection: "column",
@@ -30,8 +31,8 @@ export const downloadSourceItemHeader = style({
gap: `${SPACING_UNIT}px`,
});
-export const downloadSourceItemTitle = style({
+export const downloadSourcesHeader = style({
display: "flex",
- gap: `${SPACING_UNIT}px`,
+ justifyContent: "space-between",
alignItems: "center",
});
diff --git a/src/renderer/src/pages/settings/settings-download-sources.tsx b/src/renderer/src/pages/settings/settings-download-sources.tsx
index 7b4ddad1..ca2a1694 100644
--- a/src/renderer/src/pages/settings/settings-download-sources.tsx
+++ b/src/renderer/src/pages/settings/settings-download-sources.tsx
@@ -5,9 +5,10 @@ import { useTranslation } from "react-i18next";
import * as styles from "./settings-download-sources.css";
import type { DownloadSource } from "@types";
-import { NoEntryIcon, PlusCircleIcon } from "@primer/octicons-react";
+import { NoEntryIcon, PlusCircleIcon, SyncIcon } from "@primer/octicons-react";
import { AddDownloadSourceModal } from "./add-download-source-modal";
import { useToast } from "@renderer/hooks";
+import { DownloadSourceStatus } from "@shared";
export function SettingsDownloadSources() {
const [showAddDownloadSourceModal, setShowAddDownloadSourceModal] =
@@ -30,14 +31,19 @@ export function SettingsDownloadSources() {
const handleRemoveSource = async (id: number) => {
await window.electron.removeDownloadSource(id);
- showSuccessToast("Removed download source");
+ showSuccessToast(t("removed_download_source"));
getDownloadSources();
};
const handleAddDownloadSource = async () => {
await getDownloadSources();
- showSuccessToast("Download source successfully added");
+ showSuccessToast(t("added_download_source"));
+ };
+
+ const statusTitle = {
+ [DownloadSourceStatus.UpToDate]: t("download_source_up_to_date"),
+ [DownloadSourceStatus.Errored]: t("download_source_errored"),
};
return (
@@ -52,24 +58,34 @@ export function SettingsDownloadSources() {
{t("download_sources_description")}
-
+
+
+
+
+
{downloadSources.map((downloadSource) => (
-
-
-
{downloadSource.name}
+
{downloadSource.name}
-
{downloadSource.status}
+
+ {statusTitle[downloadSource.status]}