Skip to content
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

Merged

Conversation

tomaszbartoszewski
Copy link
Contributor

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.

README.md Outdated
}
```

Time interval in seconds for treeview auto refresh, auto refresh has to be enabled for it to work. (default is `60`):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

treeview -> tree view

if (treeViewAutoRefreshEnable) {
let treeViewAutoRefreshIntervalInSeconds = Utility.getConfig<number>(Constants.TreeViewAutoRefreshIntervalInSecondsKey);
setInterval(() => {
vscode.commands.executeCommand("azure-iot-toolkit.refresh");
Copy link
Member

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();

@@ -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) {
Copy link
Member

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.

Copy link
Member

@formulahendry formulahendry left a 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.

@tomaszbartoszewski
Copy link
Contributor Author

Thank you for your feedback, I applied all the comments, hopefully it's good now.

Copy link
Member

@formulahendry formulahendry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@formulahendry formulahendry merged commit c273f34 into microsoft:master Oct 19, 2018
@formulahendry
Copy link
Member

Awesome! Thanks @tomaszbartoszewski !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants