From f9906bfe9571d39bb4f1b66f7478e08c9c2e0a9e Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Sun, 15 Sep 2024 01:00:44 -0300 Subject: [PATCH] fix: message and migration --- src/main/knex-client.ts | 8 +++++++- .../20240915035339_ensure_repack_uris.ts | 17 +++++++++++++++++ .../modals/download-settings-modal.tsx | 15 +++++++++------ 3 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 src/main/migrations/20240915035339_ensure_repack_uris.ts diff --git a/src/main/knex-client.ts b/src/main/knex-client.ts index 9d045e3a..fe72a3de 100644 --- a/src/main/knex-client.ts +++ b/src/main/knex-client.ts @@ -3,12 +3,18 @@ import { databasePath } from "./constants"; import { Hydra2_0_3 } from "./migrations/20240830143811_Hydra_2_0_3"; import { RepackUris } from "./migrations/20240830143906_RepackUris"; import { UpdateUserLanguage } from "./migrations/20240913213944_update_user_language"; +import { EnsureRepackUris } from "./migrations/20240915035339_ensure_repack_uris"; export type HydraMigration = Knex.Migration & { name: string }; class MigrationSource implements Knex.MigrationSource { getMigrations(): Promise { - return Promise.resolve([Hydra2_0_3, RepackUris, UpdateUserLanguage]); + return Promise.resolve([ + Hydra2_0_3, + RepackUris, + UpdateUserLanguage, + EnsureRepackUris, + ]); } getMigrationName(migration: HydraMigration): string { return migration.name; diff --git a/src/main/migrations/20240915035339_ensure_repack_uris.ts b/src/main/migrations/20240915035339_ensure_repack_uris.ts new file mode 100644 index 00000000..64fbcd2e --- /dev/null +++ b/src/main/migrations/20240915035339_ensure_repack_uris.ts @@ -0,0 +1,17 @@ +import type { HydraMigration } from "@main/knex-client"; +import type { Knex } from "knex"; + +export const EnsureRepackUris: HydraMigration = { + name: "EnsureRepackUris", + up: async (knex: Knex) => { + await knex.schema.hasColumn("repack", "uris").then(async (exists) => { + if (!exists) { + await knex.schema.table("repack", (table) => { + table.text("uris").notNullable().defaultTo("[]"); + }); + } + }); + }, + + down: async (_knex: Knex) => {}, +}; diff --git a/src/renderer/src/pages/game-details/modals/download-settings-modal.tsx b/src/renderer/src/pages/game-details/modals/download-settings-modal.tsx index a301110a..35982b19 100644 --- a/src/renderer/src/pages/game-details/modals/download-settings-modal.tsx +++ b/src/renderer/src/pages/game-details/modals/download-settings-modal.tsx @@ -160,12 +160,15 @@ export function DownloadSettingsModal({ ))} - {selectedDownloader && selectedDownloader !== Downloader.Torrent && ( -

- {t("warning")}{" "} - {t("hydra_needs_to_remain_open")} -

- )} + {selectedDownloader != null && + selectedDownloader !== Downloader.Torrent && ( +

+ + {t("warning")} + {" "} + {t("hydra_needs_to_remain_open")} +

+ )}