From f81687b03a87a88988d4cce8110d015b046a7436 Mon Sep 17 00:00:00 2001
From: André Oliveira <37463445+SpecialAro@users.noreply.github.com>
Date: Tue, 21 Jun 2022 15:45:07 +0100
Subject: Fix reload after resume and add idle time setting (#324)
* Fix reload after resume issue
* Add idle time option
---
src/components/settings/settings/EditSettingsForm.js | 7 ++++++-
src/config.ts | 1 +
src/containers/settings/EditSettingsScreen.js | 10 ++++++++++
src/i18n/locales/en-US.json | 1 +
src/stores/AppStore.js | 6 ++++--
5 files changed, 22 insertions(+), 3 deletions(-)
(limited to 'src')
diff --git a/src/components/settings/settings/EditSettingsForm.js b/src/components/settings/settings/EditSettingsForm.js
index 96ae5a5ed..309be1315 100644
--- a/src/components/settings/settings/EditSettingsForm.js
+++ b/src/components/settings/settings/EditSettingsForm.js
@@ -308,7 +308,7 @@ class EditSettingsForm extends Component {
updateButtonLabelMessage = messages.buttonSearchForUpdate;
}
- const { lockingFeatureEnabled, scheduledDNDEnabled } =
+ const { lockingFeatureEnabled, scheduledDNDEnabled, reloadAfterResume } =
window['ferdium'].stores.settings.all.app;
let cacheSize;
@@ -439,6 +439,11 @@ class EditSettingsForm extends Component {
+ {reloadAfterResume && (
+
+
+
+ )}
{isWindows && }
{isWindows && }
diff --git a/src/config.ts b/src/config.ts
index a00b5c142..62b4f4e68 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -207,6 +207,7 @@ export const DEFAULT_APP_SETTINGS = {
autoLaunchInBackground: false,
runInBackground: true,
reloadAfterResume: true,
+ reloadAfterResumeTime: 10,
enableSystemTray: true,
startMinimized: false,
confirmOnQuit: false,
diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js
index bae19d3b6..898a2f482 100644
--- a/src/containers/settings/EditSettingsScreen.js
+++ b/src/containers/settings/EditSettingsScreen.js
@@ -74,6 +74,10 @@ const messages = defineMessages({
id: 'settings.app.form.reloadAfterResume',
defaultMessage: 'Reload Ferdium after system resume',
},
+ reloadAfterResumeTime: {
+ id: 'settings.app.form.reloadAfterResumeTime',
+ defaultMessage: 'Time to consider the system as idle/suspended (in minutes)',
+ },
minimizeToSystemTray: {
id: 'settings.app.form.minimizeToSystemTray',
defaultMessage: 'Minimize Ferdium to system tray',
@@ -323,6 +327,7 @@ class EditSettingsScreen extends Component {
runInBackground: Boolean(settingsData.runInBackground),
enableSystemTray: Boolean(settingsData.enableSystemTray),
reloadAfterResume: Boolean(settingsData.reloadAfterResume),
+ reloadAfterResumeTime: Number(settingsData.reloadAfterResumeTime),
startMinimized: Boolean(settingsData.startMinimized),
confirmOnQuit: Boolean(settingsData.confirmOnQuit),
minimizeToSystemTray: Boolean(settingsData.minimizeToSystemTray),
@@ -516,6 +521,11 @@ class EditSettingsScreen extends Component {
value: settings.all.app.reloadAfterResume,
default: DEFAULT_APP_SETTINGS.reloadAfterResume,
},
+ reloadAfterResumeTime: {
+ label: intl.formatMessage(messages.reloadAfterResumeTime),
+ value: settings.all.app.reloadAfterResumeTime,
+ default: DEFAULT_APP_SETTINGS.reloadAfterResumeTime,
+ },
minimizeToSystemTray: {
label: intl.formatMessage(messages.minimizeToSystemTray),
value: settings.all.app.minimizeToSystemTray,
diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json
index 84dec5515..be6d68f3a 100644
--- a/src/i18n/locales/en-US.json
+++ b/src/i18n/locales/en-US.json
@@ -233,6 +233,7 @@
"settings.app.form.privateNotifications": "Don't show message content in notifications",
"settings.app.form.progressbarAccentColor": "Progressbar Accent color",
"settings.app.form.reloadAfterResume": "Reload Ferdium after system resume",
+ "settings.app.form.reloadAfterResumeTime": "Time to consider the system as idle/suspended (in minutes)",
"settings.app.form.runInBackground": "Keep Ferdium in background when closing the window",
"settings.app.form.scheduledDNDEnabled": "Enable scheduled Do-not-Disturb",
"settings.app.form.scheduledDNDEnd": "To",
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
index 2d85b9ffe..a8e1ce247 100644
--- a/src/stores/AppStore.js
+++ b/src/stores/AppStore.js
@@ -232,9 +232,11 @@ export default class AppStore extends Store {
debug('System resumed, last suspended on', this.timeSuspensionStart);
this.actions.service.resetLastPollTimer();
+ const idleTime = this.stores.settings.app.reloadAfterResumeTime;
+
if (
- this.timeSuspensionStart.add(10, 'm').isBefore(moment()) &&
- this.stores.settings.app.get('reloadAfterResume')
+ this.timeSuspensionStart.add(idleTime, 'm').isBefore(moment()) &&
+ this.stores.settings.app.reloadAfterResume
) {
debug('Reloading services, user info and features');
--
cgit v1.2.3-70-g09d2