feat(options): restart when setting locale

This commit is contained in:
Elian Doran 2025-03-25 20:15:39 +02:00
parent a5a7a30cd5
commit ab58671625
No known key found for this signature in database
3 changed files with 14 additions and 5 deletions

View File

@ -10,6 +10,17 @@ function reloadFrontendApp(reason?: string) {
window.location.reload(); window.location.reload();
} }
function restartDesktopApp() {
if (!isElectron()) {
reloadFrontendApp();
return;
}
const app = dynamicRequire("@electron/remote").app;
app.relaunch();
app.exit();
}
/** /**
* Triggers the system tray to update its menu items, i.e. after a change in dynamic content such as bookmarks or recent notes. * Triggers the system tray to update its menu items, i.e. after a change in dynamic content such as bookmarks or recent notes.
* *
@ -739,6 +750,7 @@ function isLaunchBarConfig(noteId: string) {
export default { export default {
reloadFrontendApp, reloadFrontendApp,
restartDesktopApp,
reloadTray, reloadTray,
parseDate, parseDate,
getMonthsInDateRange, getMonthsInDateRange,

View File

@ -61,11 +61,7 @@ export default class ElectronIntegrationOptions extends OptionsWidget {
this.$backgroundEffects.on("change", () => this.updateCheckboxOption("backgroundEffects", this.$backgroundEffects)); this.$backgroundEffects.on("change", () => this.updateCheckboxOption("backgroundEffects", this.$backgroundEffects));
const restartAppButton = this.$widget.find(".restart-app-button"); const restartAppButton = this.$widget.find(".restart-app-button");
restartAppButton.on("click", () => { restartAppButton.on("click", utils.restartDesktopApp);
const app = utils.dynamicRequire("@electron/remote").app;
app.relaunch();
app.exit();
});
} }
isEnabled() { isEnabled() {

View File

@ -59,6 +59,7 @@ export default class LocalizationOptions extends OptionsWidget {
this.$formattingLocaleSelect.on("change", async () => { this.$formattingLocaleSelect.on("change", async () => {
const newLocale = this.$formattingLocaleSelect.val(); const newLocale = this.$formattingLocaleSelect.val();
await server.put(`options/formattingLocale/${newLocale}`); await server.put(`options/formattingLocale/${newLocale}`);
utils.restartDesktopApp();
}); });
this.$widget.find(`input[name="first-day-of-week"]`).on("change", () => { this.$widget.find(`input[name="first-day-of-week"]`).on("change", () => {