From f89cf9726e204b569e190f85923f7756169ab018 Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Tue, 22 Oct 2019 12:03:03 -0400 Subject: [PATCH] Only refresh if VSCode is in focus (#1352) * Only refresh if VSCode is in focus * Change default refresh rate to 2s --- package.json | 4 ++-- src/tree/LocalRootTreeItemBase.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 4d0f0c9a75..61a2337663 100644 --- a/package.json +++ b/package.json @@ -1092,8 +1092,8 @@ }, "docker.explorerRefreshInterval": { "type": "number", - "default": 1000, - "description": "Explorer refresh interval, default is 1000ms" + "default": 2000, + "description": "Explorer refresh interval, default is 2000ms" }, "docker.containers.groupBy": { "type": "string", diff --git a/src/tree/LocalRootTreeItemBase.ts b/src/tree/LocalRootTreeItemBase.ts index bb44a6de1a..c87a843fcf 100644 --- a/src/tree/LocalRootTreeItemBase.ts +++ b/src/tree/LocalRootTreeItemBase.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See LICENSE.md in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ConfigurationChangeEvent, ConfigurationTarget, TreeView, TreeViewVisibilityChangeEvent, workspace, WorkspaceConfiguration } from "vscode"; +import { ConfigurationChangeEvent, ConfigurationTarget, TreeView, TreeViewVisibilityChangeEvent, window, workspace, WorkspaceConfiguration } from "vscode"; import { AzExtParentTreeItem, AzExtTreeItem, AzureWizard, GenericTreeItem, IActionContext, InvalidTreeItem, registerEvent } from "vscode-azureextensionui"; import { configPrefix } from "../constants"; import { ext } from "../extensionVariables"; @@ -74,10 +74,10 @@ export abstract class LocalRootTreeItemBase('explorerRefreshInterval', 1000); + const refreshInterval: number = configOptions.get('explorerRefreshInterval', 2000); intervalId = setInterval( async () => { - if (await this.hasChanged()) { + if (window.state.focused && await this.hasChanged()) { await this.refresh(); } },