diff --git a/src/main/knex-client.ts b/src/main/knex-client.ts index 031760f6..9d045e3a 100644 --- a/src/main/knex-client.ts +++ b/src/main/knex-client.ts @@ -2,12 +2,13 @@ import knex, { Knex } from "knex"; 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"; export type HydraMigration = Knex.Migration & { name: string }; class MigrationSource implements Knex.MigrationSource { getMigrations(): Promise { - return Promise.resolve([Hydra2_0_3, RepackUris]); + return Promise.resolve([Hydra2_0_3, RepackUris, UpdateUserLanguage]); } getMigrationName(migration: HydraMigration): string { return migration.name; diff --git a/src/main/migrations/20240913213944_update_user_language.ts b/src/main/migrations/20240913213944_update_user_language.ts new file mode 100644 index 00000000..3297eb0d --- /dev/null +++ b/src/main/migrations/20240913213944_update_user_language.ts @@ -0,0 +1,13 @@ +import type { HydraMigration } from "@main/knex-client"; +import type { Knex } from "knex"; + +export const UpdateUserLanguage: HydraMigration = { + name: "UpdateUserLanguage", + up: async (knex: Knex) => { + await knex("user_preferences") + .update("language", "pt-BR") + .where("language", "pt"); + }, + + down: async (_knex: Knex) => {}, +}; diff --git a/src/renderer/src/main.tsx b/src/renderer/src/main.tsx index 2377bf7c..3cf1b9a1 100644 --- a/src/renderer/src/main.tsx +++ b/src/renderer/src/main.tsx @@ -41,8 +41,11 @@ i18n escapeValue: false, }, }) - .then(() => { - window.electron.updateUserPreferences({ language: i18n.language }); + .then(async () => { + const userPreferences = await window.electron.getUserPreferences(); + if (!userPreferences?.language) { + window.electron.updateUserPreferences({ language: i18n.language }); + } }); ReactDOM.createRoot(document.getElementById("root")!).render(