mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-15 04:32:13 +00:00
Merge pull request #953 from hydralauncher/fix/add-language-migration
feat: add language migration
This commit is contained in:
commit
7846ecbd4f
3 changed files with 20 additions and 3 deletions
|
@ -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<HydraMigration> {
|
||||
getMigrations(): Promise<HydraMigration[]> {
|
||||
return Promise.resolve([Hydra2_0_3, RepackUris]);
|
||||
return Promise.resolve([Hydra2_0_3, RepackUris, UpdateUserLanguage]);
|
||||
}
|
||||
getMigrationName(migration: HydraMigration): string {
|
||||
return migration.name;
|
||||
|
|
13
src/main/migrations/20240913213944_update_user_language.ts
Normal file
13
src/main/migrations/20240913213944_update_user_language.ts
Normal file
|
@ -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) => {},
|
||||
};
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue