fix: update i18n in updateUserPreferences and in hydra startup

This commit is contained in:
Zamitto 2024-06-29 14:34:30 -03:00
parent 77152a32ab
commit 8a5d4e38b6
2 changed files with 12 additions and 2 deletions

View File

@ -2,17 +2,23 @@ import { userPreferencesRepository } from "@main/repository";
import { registerEvent } from "../register-event";
import type { UserPreferences } from "@types";
import i18next from "i18next";
const updateUserPreferences = async (
_event: Electron.IpcMainInvokeEvent,
preferences: Partial<UserPreferences>
) =>
userPreferencesRepository.upsert(
) => {
if (preferences.language) {
i18next.changeLanguage(preferences.language);
}
return userPreferencesRepository.upsert(
{
id: 1,
...preferences,
},
["id"]
);
};
registerEvent("updateUserPreferences", updateUserPreferences);

View File

@ -72,6 +72,10 @@ app.whenReady().then(async () => {
where: { id: 1 },
});
if (userPreferences?.language) {
i18n.changeLanguage(userPreferences.language);
}
WindowManager.createMainWindow();
WindowManager.createSystemTray(userPreferences?.language || "en");
});