-
Notifications
You must be signed in to change notification settings - Fork 243
feat: Add Recipe poll interval configuration #2264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
aa863dd
3928af3
6a219e1
bc339d7
54c07db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -126,6 +126,8 @@ export default class Service { | |
|
|
||
| @observable lastHibernated: number | null = null; // timestamp | ||
|
|
||
| @observable pollDelay: number = DEFAULT_SERVICE_SETTINGS.pollDelay; // interval for Recipe Polling | ||
|
|
||
| @observable lastPoll: number = Date.now(); | ||
|
|
||
| @observable lastPollAnswer: number = Date.now(); | ||
|
|
@@ -237,7 +239,11 @@ export default class Service { | |
| data.isWakeUpEnabled, | ||
| this.isWakeUpEnabled, | ||
| ); | ||
|
|
||
| this.pollDelay = ifUndefined<number>( | ||
| recipe.pollDelay <= data.pollDelay ? data.pollDelay : recipe.pollDelay, | ||
| this.pollDelay, | ||
| ); | ||
| // console.log('ctor-recipe', recipe); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove comments used to test out things. |
||
| // Check if "Hibernate on Startup" is enabled and hibernate all services except active one | ||
| const { hibernateOnStartup } = window['ferdium'].stores.settings.app; | ||
| // The service store is probably not loaded yet so we need to use localStorage data to get active service | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,8 +58,13 @@ class RecipeWebview { | |
| * Initialize the loop | ||
| * | ||
| * @param {Function} Function that will be executed | ||
| * @param {String} Interval which drive the loop in `ms` library format | ||
| */ | ||
| loop(fn) { | ||
| loop(fn, interval) { | ||
| if (interval && typeof interval === 'string') { | ||
| ipcRenderer.sendToHost('set-loop-delay', interval); | ||
| } | ||
|
Comment on lines
+63
to
+66
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you really want to make a change happen from the recipe webview, I would prefer you to create a new function there like
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that you've removed the listener |
||
|
|
||
| this.loopFunc = fn; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the current state of things, this has no impact because you don't allow the user to modify the value. In order for it to do something you need to modify the files
EditServiceForm.tsxandEditServiceScreen.tsxin order to add a field where the user can input the value (which will appear on the window that allows for adding/modifying a service). Make sure to validate the value entered appropriately.As for this line explicitly: why would you prevent a user from entering a value smaller than what the recipe suggests? At the current stage, since no recipe has a given value, the polling time is the default 2sec, and users would like to poll more often. This would prevent the user to input a lower value when initially creating the service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Alphrag

I already made some changes (I would like to improve my knowledge of Ferdium) and this is a first result
In this case, can be an useful integration add a switch (Enable/Disable Poll Delay) and show this customization only if the user would like to personalize the delay of the poll
Also, than you have more experiences on this project, did you know some validation (already coded) for numeric input? I'm asking this, because I can't found nothing about. I would like to avoid duplicated code.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
I leave the decision to you to either add a switch to enable/disable custom poll delay (where toggling off resets to the recipe's poll delay value), or to simply allow an empty value, which is the default and corresponds to the recipe's delay. We do the latter in other places of the code, for example, to handle the
accentColorfield on the general settings, and the important part is how we validate that field —which in that case required dynamic handling whereas here we won't need that (cfEditSettingsForm.tsx)—.I honestly don't remember of having a specific function that validates numeric input (they would normally be located in the
helpersfolder) and since you simply need to check the value that is passed is an integer, aNumber.isIntegercheck would probably suffice, don't you think?