mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 21:44:55 +03:00
feat: add language migration
This commit is contained in:
parent
863a3b7d1f
commit
2ea6285744
@ -2,12 +2,13 @@ import knex, { Knex } from "knex";
|
|||||||
import { databasePath } from "./constants";
|
import { databasePath } from "./constants";
|
||||||
import { Hydra2_0_3 } from "./migrations/20240830143811_Hydra_2_0_3";
|
import { Hydra2_0_3 } from "./migrations/20240830143811_Hydra_2_0_3";
|
||||||
import { RepackUris } from "./migrations/20240830143906_RepackUris";
|
import { RepackUris } from "./migrations/20240830143906_RepackUris";
|
||||||
|
import { UpdateUserLanguage } from "./migrations/20240913213944_update_user_language";
|
||||||
|
|
||||||
export type HydraMigration = Knex.Migration & { name: string };
|
export type HydraMigration = Knex.Migration & { name: string };
|
||||||
|
|
||||||
class MigrationSource implements Knex.MigrationSource<HydraMigration> {
|
class MigrationSource implements Knex.MigrationSource<HydraMigration> {
|
||||||
getMigrations(): Promise<HydraMigration[]> {
|
getMigrations(): Promise<HydraMigration[]> {
|
||||||
return Promise.resolve([Hydra2_0_3, RepackUris]);
|
return Promise.resolve([Hydra2_0_3, RepackUris, UpdateUserLanguage]);
|
||||||
}
|
}
|
||||||
getMigrationName(migration: HydraMigration): string {
|
getMigrationName(migration: HydraMigration): string {
|
||||||
return migration.name;
|
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,
|
escapeValue: false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(async () => {
|
||||||
window.electron.updateUserPreferences({ language: i18n.language });
|
const userPreferences = await window.electron.getUserPreferences();
|
||||||
|
if (!userPreferences?.language) {
|
||||||
|
window.electron.updateUserPreferences({ language: i18n.language });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ReactDOM.createRoot(document.getElementById("root")!).render(
|
ReactDOM.createRoot(document.getElementById("root")!).render(
|
||||||
|
Loading…
Reference in New Issue
Block a user