diff options
author | 2024-05-08 02:54:03 +0100 | |
---|---|---|
committer | 2024-05-08 07:24:03 +0530 | |
commit | b0fa45f1840b3dc369b474d8820a5914bbcb5b69 (patch) | |
tree | 023319639e9a0edff363b7b93c106e466843ece8 /src/containers/settings | |
parent | 6.7.4-nightly.6 [skip ci] (diff) | |
download | ferdium-app-b0fa45f1840b3dc369b474d8820a5914bbcb5b69.tar.gz ferdium-app-b0fa45f1840b3dc369b474d8820a5914bbcb5b69.tar.zst ferdium-app-b0fa45f1840b3dc369b474d8820a5914bbcb5b69.zip |
feat: prompt the user to restart ferdium on some settings changes (#1748)
Diffstat (limited to 'src/containers/settings')
-rw-r--r-- | src/containers/settings/EditSettingsScreen.tsx | 232 |
1 files changed, 143 insertions, 89 deletions
diff --git a/src/containers/settings/EditSettingsScreen.tsx b/src/containers/settings/EditSettingsScreen.tsx index a596e53a3..31e8d6484 100644 --- a/src/containers/settings/EditSettingsScreen.tsx +++ b/src/containers/settings/EditSettingsScreen.tsx | |||
@@ -346,6 +346,27 @@ const messages = defineMessages({ | |||
346 | defaultMessage: | 346 | defaultMessage: |
347 | 'Default download folder (leave blank to be prompted for each download)', | 347 | 'Default download folder (leave blank to be prompted for each download)', |
348 | }, | 348 | }, |
349 | restartDialogTitle: { | ||
350 | id: 'settings.app.restart.restartDialogTitle', | ||
351 | defaultMessage: 'Ferdium - Relaunch Application', | ||
352 | }, | ||
353 | restartNow: { | ||
354 | id: 'settings.app.restart.restartNow', | ||
355 | defaultMessage: 'Restart now', | ||
356 | }, | ||
357 | restartLater: { | ||
358 | id: 'settings.app.restart.restartLater', | ||
359 | defaultMessage: 'Restart later', | ||
360 | }, | ||
361 | restartDialogMessage: { | ||
362 | id: 'settings.app.restart.restartDialogMessage', | ||
363 | defaultMessage: 'Do you want to relaunch Ferdium?', | ||
364 | }, | ||
365 | restartDialogDetail: { | ||
366 | id: 'settings.app.restart.restartDialogDetail', | ||
367 | defaultMessage: | ||
368 | 'You made a change that requires a restart. This will close Ferdium and restart it.', | ||
369 | }, | ||
349 | }); | 370 | }); |
350 | 371 | ||
351 | interface EditSettingsScreenProps extends StoresProps, WrappedComponentProps {} | 372 | interface EditSettingsScreenProps extends StoresProps, WrappedComponentProps {} |
@@ -369,6 +390,7 @@ class EditSettingsScreen extends Component< | |||
369 | } | 390 | } |
370 | 391 | ||
371 | onSubmit(settingsData) { | 392 | onSubmit(settingsData) { |
393 | const { intl } = this.props; | ||
372 | const { todos, workspaces } = this.props.stores; | 394 | const { todos, workspaces } = this.props.stores; |
373 | const { | 395 | const { |
374 | app, | 396 | app, |
@@ -391,98 +413,130 @@ class EditSettingsScreen extends Component< | |||
391 | 413 | ||
392 | debug(`Updating settings store with data: ${settingsData}`); | 414 | debug(`Updating settings store with data: ${settingsData}`); |
393 | 415 | ||
416 | const { app: currentSettings } = this.props.stores.settings.all; | ||
417 | |||
418 | const newSettings = { | ||
419 | runInBackground: Boolean(settingsData.runInBackground), | ||
420 | enableSystemTray: Boolean(settingsData.enableSystemTray), | ||
421 | reloadAfterResume: Boolean(settingsData.reloadAfterResume), | ||
422 | reloadAfterResumeTime: Number(settingsData.reloadAfterResumeTime), | ||
423 | startMinimized: Boolean(settingsData.startMinimized), | ||
424 | confirmOnQuit: Boolean(settingsData.confirmOnQuit), | ||
425 | minimizeToSystemTray: Boolean(settingsData.minimizeToSystemTray), | ||
426 | closeToSystemTray: Boolean(settingsData.closeToSystemTray), | ||
427 | privateNotifications: Boolean(settingsData.privateNotifications), | ||
428 | clipboardNotifications: Boolean(settingsData.clipboardNotifications), | ||
429 | notifyTaskBarOnMessage: Boolean(settingsData.notifyTaskBarOnMessage), | ||
430 | isTwoFactorAutoCatcherEnabled: Boolean( | ||
431 | settingsData.isTwoFactorAutoCatcherEnabled, | ||
432 | ), | ||
433 | twoFactorAutoCatcherMatcher: settingsData.twoFactorAutoCatcherMatcher, | ||
434 | navigationBarBehaviour: settingsData.navigationBarBehaviour, | ||
435 | webRTCIPHandlingPolicy: settingsData.webRTCIPHandlingPolicy, | ||
436 | searchEngine: settingsData.searchEngine, | ||
437 | translatorEngine: settingsData.translatorEngine, | ||
438 | translatorLanguage: settingsData.translatorLanguage, | ||
439 | sentry: Boolean(settingsData.sentry), | ||
440 | hibernateOnStartup: Boolean(settingsData.hibernateOnStartup), | ||
441 | hibernationStrategy: Number(settingsData.hibernationStrategy), | ||
442 | wakeUpStrategy: Number(settingsData.wakeUpStrategy), | ||
443 | wakeUpHibernationStrategy: Number(settingsData.wakeUpHibernationStrategy), | ||
444 | wakeUpHibernationSplay: Boolean(settingsData.wakeUpHibernationSplay), | ||
445 | predefinedTodoServer: settingsData.predefinedTodoServer, | ||
446 | customTodoServer: settingsData.customTodoServer, | ||
447 | isLockingFeatureEnabled: Boolean(settingsData.isLockingFeatureEnabled), | ||
448 | lockedPassword: useOriginalPassword | ||
449 | ? this.props.stores.settings.all.app.lockedPassword | ||
450 | : hash(String(settingsData.lockedPassword)), | ||
451 | useTouchIdToUnlock: Boolean(settingsData.useTouchIdToUnlock), | ||
452 | inactivityLock: Number(settingsData.inactivityLock), | ||
453 | scheduledDNDEnabled: Boolean(settingsData.scheduledDNDEnabled), | ||
454 | scheduledDNDStart: settingsData.scheduledDNDStart, | ||
455 | scheduledDNDEnd: settingsData.scheduledDNDEnd, | ||
456 | enableGPUAcceleration: Boolean(settingsData.enableGPUAcceleration), | ||
457 | downloadFolderPath: String(settingsData.downloadFolderPath), | ||
458 | enableGlobalHideShortcut: Boolean(settingsData.enableGlobalHideShortcut), | ||
459 | showDisabledServices: Boolean(settingsData.showDisabledServices), | ||
460 | showServiceName: Boolean(settingsData.showServiceName), | ||
461 | darkMode: Boolean(settingsData.darkMode), | ||
462 | adaptableDarkMode: Boolean(settingsData.adaptableDarkMode), | ||
463 | universalDarkMode: Boolean(settingsData.universalDarkMode), | ||
464 | splitMode: Boolean(settingsData.splitMode), | ||
465 | splitColumns: Number(settingsData.splitColumns), | ||
466 | serviceRibbonWidth: Number(settingsData.serviceRibbonWidth), | ||
467 | sidebarServicesLocation: Number(settingsData.sidebarServicesLocation), | ||
468 | iconSize: Number(settingsData.iconSize), | ||
469 | enableLongPressServiceHint: Boolean( | ||
470 | settingsData.enableLongPressServiceHint, | ||
471 | ), | ||
472 | useHorizontalStyle: Boolean(settingsData.useHorizontalStyle), | ||
473 | hideCollapseButton: Boolean(settingsData.hideCollapseButton), | ||
474 | hideRecipesButton: Boolean(settingsData.hideRecipesButton), | ||
475 | hideSplitModeButton: Boolean(settingsData.hideSplitModeButton), | ||
476 | useGrayscaleServices: Boolean(settingsData.useGrayscaleServices), | ||
477 | grayscaleServicesDim: Number(settingsData.grayscaleServicesDim), | ||
478 | hideWorkspacesButton: Boolean(settingsData.hideWorkspacesButton), | ||
479 | hideNotificationsButton: Boolean(settingsData.hideNotificationsButton), | ||
480 | hideSettingsButton: Boolean(settingsData.hideSettingsButton), | ||
481 | hideDownloadButton: Boolean(settingsData.hideDownloadButton), | ||
482 | alwaysShowWorkspaces: Boolean(settingsData.alwaysShowWorkspaces), | ||
483 | hideAllServicesWorkspace: Boolean(settingsData.hideAllServicesWorkspace), | ||
484 | accentColor: settingsData.accentColor, | ||
485 | progressbarAccentColor: settingsData.progressbarAccentColor, | ||
486 | showMessageBadgeWhenMuted: Boolean( | ||
487 | settingsData.showMessageBadgeWhenMuted, | ||
488 | ), | ||
489 | showDragArea: Boolean(settingsData.showDragArea), | ||
490 | enableSpellchecking: Boolean(settingsData.enableSpellchecking), | ||
491 | enableTranslator: Boolean(settingsData.enableTranslator), | ||
492 | useSelfSignedCertificates: Boolean( | ||
493 | settingsData.useSelfSignedCertificates, | ||
494 | ), | ||
495 | spellcheckerLanguage: settingsData.spellcheckerLanguage, | ||
496 | userAgentPref: settingsData.userAgentPref, | ||
497 | beta: Boolean(settingsData.beta), // we need this info in the main process as well | ||
498 | automaticUpdates: Boolean(settingsData.automaticUpdates), // we need this info in the main process as well | ||
499 | locale: settingsData.locale, // we need this info in the main process as well | ||
500 | }; | ||
501 | |||
502 | const requiredRestartKeys = [ | ||
503 | 'webRTCIPHandlingPolicy', | ||
504 | 'sentry', | ||
505 | 'searchEngine', | ||
506 | 'enableSpellchecking', | ||
507 | 'spellcheckerLanguage', | ||
508 | 'enableGlobalHideShortcut', | ||
509 | // 'userAgentPref', // TODO: this is an input field, so it changes on every key stroke | ||
510 | ]; | ||
511 | |||
512 | // Check if any of the keys that require a restart have changed | ||
513 | const requiresRestart = requiredRestartKeys.some( | ||
514 | key => newSettings[key] !== currentSettings[key], | ||
515 | ); | ||
516 | |||
517 | if (requiresRestart) { | ||
518 | debug('Settings require restart'); | ||
519 | |||
520 | const options: Electron.MessageBoxOptions = { | ||
521 | type: 'warning', | ||
522 | buttons: [ | ||
523 | intl.formatMessage(messages.restartNow), | ||
524 | intl.formatMessage(messages.restartLater), | ||
525 | ], | ||
526 | defaultId: 0, | ||
527 | cancelId: 1, | ||
528 | title: intl.formatMessage(messages.restartDialogTitle), | ||
529 | message: intl.formatMessage(messages.restartDialogMessage), | ||
530 | detail: intl.formatMessage(messages.restartDialogDetail), | ||
531 | }; | ||
532 | |||
533 | ipcRenderer.send('relaunch-app', options); | ||
534 | } | ||
535 | |||
394 | settings.update({ | 536 | settings.update({ |
395 | type: 'app', | 537 | type: 'app', |
396 | // TODO: The conversions might not be necessary once we convert to typescript | 538 | // TODO: The conversions might not be necessary once we convert to typescript |
397 | data: { | 539 | data: newSettings, |
398 | runInBackground: Boolean(settingsData.runInBackground), | ||
399 | enableSystemTray: Boolean(settingsData.enableSystemTray), | ||
400 | reloadAfterResume: Boolean(settingsData.reloadAfterResume), | ||
401 | reloadAfterResumeTime: Number(settingsData.reloadAfterResumeTime), | ||
402 | startMinimized: Boolean(settingsData.startMinimized), | ||
403 | confirmOnQuit: Boolean(settingsData.confirmOnQuit), | ||
404 | minimizeToSystemTray: Boolean(settingsData.minimizeToSystemTray), | ||
405 | closeToSystemTray: Boolean(settingsData.closeToSystemTray), | ||
406 | privateNotifications: Boolean(settingsData.privateNotifications), | ||
407 | clipboardNotifications: Boolean(settingsData.clipboardNotifications), | ||
408 | notifyTaskBarOnMessage: Boolean(settingsData.notifyTaskBarOnMessage), | ||
409 | isTwoFactorAutoCatcherEnabled: Boolean( | ||
410 | settingsData.isTwoFactorAutoCatcherEnabled, | ||
411 | ), | ||
412 | twoFactorAutoCatcherMatcher: settingsData.twoFactorAutoCatcherMatcher, | ||
413 | navigationBarBehaviour: settingsData.navigationBarBehaviour, | ||
414 | webRTCIPHandlingPolicy: settingsData.webRTCIPHandlingPolicy, | ||
415 | searchEngine: settingsData.searchEngine, | ||
416 | translatorEngine: settingsData.translatorEngine, | ||
417 | translatorLanguage: settingsData.translatorLanguage, | ||
418 | sentry: Boolean(settingsData.sentry), | ||
419 | hibernateOnStartup: Boolean(settingsData.hibernateOnStartup), | ||
420 | hibernationStrategy: Number(settingsData.hibernationStrategy), | ||
421 | wakeUpStrategy: Number(settingsData.wakeUpStrategy), | ||
422 | wakeUpHibernationStrategy: Number( | ||
423 | settingsData.wakeUpHibernationStrategy, | ||
424 | ), | ||
425 | wakeUpHibernationSplay: Boolean(settingsData.wakeUpHibernationSplay), | ||
426 | predefinedTodoServer: settingsData.predefinedTodoServer, | ||
427 | customTodoServer: settingsData.customTodoServer, | ||
428 | isLockingFeatureEnabled: Boolean(settingsData.isLockingFeatureEnabled), | ||
429 | lockedPassword: useOriginalPassword | ||
430 | ? this.props.stores.settings.all.app.lockedPassword | ||
431 | : hash(String(settingsData.lockedPassword)), | ||
432 | useTouchIdToUnlock: Boolean(settingsData.useTouchIdToUnlock), | ||
433 | inactivityLock: Number(settingsData.inactivityLock), | ||
434 | scheduledDNDEnabled: Boolean(settingsData.scheduledDNDEnabled), | ||
435 | scheduledDNDStart: settingsData.scheduledDNDStart, | ||
436 | scheduledDNDEnd: settingsData.scheduledDNDEnd, | ||
437 | enableGPUAcceleration: Boolean(settingsData.enableGPUAcceleration), | ||
438 | downloadFolderPath: String(settingsData.downloadFolderPath), | ||
439 | enableGlobalHideShortcut: Boolean( | ||
440 | settingsData.enableGlobalHideShortcut, | ||
441 | ), | ||
442 | showDisabledServices: Boolean(settingsData.showDisabledServices), | ||
443 | showServiceName: Boolean(settingsData.showServiceName), | ||
444 | darkMode: Boolean(settingsData.darkMode), | ||
445 | adaptableDarkMode: Boolean(settingsData.adaptableDarkMode), | ||
446 | universalDarkMode: Boolean(settingsData.universalDarkMode), | ||
447 | splitMode: Boolean(settingsData.splitMode), | ||
448 | splitColumns: Number(settingsData.splitColumns), | ||
449 | serviceRibbonWidth: Number(settingsData.serviceRibbonWidth), | ||
450 | sidebarServicesLocation: Number(settingsData.sidebarServicesLocation), | ||
451 | iconSize: Number(settingsData.iconSize), | ||
452 | enableLongPressServiceHint: Boolean( | ||
453 | settingsData.enableLongPressServiceHint, | ||
454 | ), | ||
455 | useHorizontalStyle: Boolean(settingsData.useHorizontalStyle), | ||
456 | hideCollapseButton: Boolean(settingsData.hideCollapseButton), | ||
457 | hideRecipesButton: Boolean(settingsData.hideRecipesButton), | ||
458 | hideSplitModeButton: Boolean(settingsData.hideSplitModeButton), | ||
459 | useGrayscaleServices: Boolean(settingsData.useGrayscaleServices), | ||
460 | grayscaleServicesDim: Number(settingsData.grayscaleServicesDim), | ||
461 | hideWorkspacesButton: Boolean(settingsData.hideWorkspacesButton), | ||
462 | hideNotificationsButton: Boolean(settingsData.hideNotificationsButton), | ||
463 | hideSettingsButton: Boolean(settingsData.hideSettingsButton), | ||
464 | hideDownloadButton: Boolean(settingsData.hideDownloadButton), | ||
465 | alwaysShowWorkspaces: Boolean(settingsData.alwaysShowWorkspaces), | ||
466 | hideAllServicesWorkspace: Boolean( | ||
467 | settingsData.hideAllServicesWorkspace, | ||
468 | ), | ||
469 | accentColor: settingsData.accentColor, | ||
470 | progressbarAccentColor: settingsData.progressbarAccentColor, | ||
471 | showMessageBadgeWhenMuted: Boolean( | ||
472 | settingsData.showMessageBadgeWhenMuted, | ||
473 | ), | ||
474 | showDragArea: Boolean(settingsData.showDragArea), | ||
475 | enableSpellchecking: Boolean(settingsData.enableSpellchecking), | ||
476 | enableTranslator: Boolean(settingsData.enableTranslator), | ||
477 | useSelfSignedCertificates: Boolean( | ||
478 | settingsData.useSelfSignedCertificates, | ||
479 | ), | ||
480 | spellcheckerLanguage: settingsData.spellcheckerLanguage, | ||
481 | userAgentPref: settingsData.userAgentPref, | ||
482 | beta: Boolean(settingsData.beta), // we need this info in the main process as well | ||
483 | automaticUpdates: Boolean(settingsData.automaticUpdates), // we need this info in the main process as well | ||
484 | locale: settingsData.locale, // we need this info in the main process as well | ||
485 | }, | ||
486 | }); | 540 | }); |
487 | 541 | ||
488 | user.update({ | 542 | user.update({ |