-
Notifications
You must be signed in to change notification settings - Fork 59
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
(GH-96) Add auto refresh with configuration to enable it and set refresh interval #184
(GH-96) Add auto refresh with configuration to enable it and set refresh interval #184
Conversation
… set refresh interval
README.md
Outdated
} | ||
``` | ||
|
||
Time interval in seconds for treeview auto refresh, auto refresh has to be enabled for it to work. (default is `60`): |
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.
treeview
-> tree view
src/deviceTree.ts
Outdated
if (treeViewAutoRefreshEnable) { | ||
let treeViewAutoRefreshIntervalInSeconds = Utility.getConfig<number>(Constants.TreeViewAutoRefreshIntervalInSecondsKey); | ||
setInterval(() => { | ||
vscode.commands.executeCommand("azure-iot-toolkit.refresh"); |
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.
Here could just use this._onDidChangeTreeData.fire();
src/deviceTree.ts
Outdated
@@ -12,6 +12,13 @@ export class DeviceTree implements vscode.TreeDataProvider<vscode.TreeItem> { | |||
public readonly onDidChangeTreeData: vscode.Event<vscode.TreeItem | undefined> = this._onDidChangeTreeData.event; | |||
|
|||
constructor(private context: vscode.ExtensionContext) { | |||
let treeViewAutoRefreshEnable = Utility.getConfig<boolean>(Constants.TreeViewAutoRefreshEnableKey); | |||
if (treeViewAutoRefreshEnable) { |
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.
Think about the scenario: The interval is set as 5 seconds, while the tree view takes 8 seconds to render.
Same with your concern, would better to put this logic into getChildren()
, setInterval
after tree view is rendered,
If the logic is in getChildren()
, we also need to clearTimeout
for previous setInterval
.
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.
Some comments, and I am OK with the setting name and default value.
Thank you for your feedback, I applied all the comments, hopefully it's good now. |
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.
Awesome! Thanks @tomaszbartoszewski ! |
There are few things, I'm not sure about. The name for settings is one thing. I set default interval to 60 seconds, as I thought it's better than too low value, in case somebody enables it by accident, but maybe it should be higher. The biggest concern I have is about
setInterval
inside constructor and reading config there, if there is a better way of doing it, I'm happy to improve my code.