From 021193827c39d00089d26a22f29078c3f7e7cc57 Mon Sep 17 00:00:00 2001 From: Rhys Date: Wed, 7 Jul 2021 10:47:21 -0400 Subject: [PATCH] fix(tree-explorer): dont show message when cannot fetch estimated count VSCODE-268 (#309) --- src/explorer/collectionTreeItem.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/explorer/collectionTreeItem.ts b/src/explorer/collectionTreeItem.ts index 425454fb..a61e4529 100644 --- a/src/explorer/collectionTreeItem.ts +++ b/src/explorer/collectionTreeItem.ts @@ -1,5 +1,5 @@ import * as vscode from 'vscode'; -const path = require('path'); +import path from 'path'; import { createLogger } from '../logging'; import DocumentListTreeItem, { @@ -73,7 +73,7 @@ export default class CollectionTreeItem extends vscode.TreeItem private _dataService: any; private _type: CollectionTypes; - documentCount: number | null; + documentCount: number | null = null; isExpanded: boolean; @@ -333,14 +333,20 @@ export default class CollectionTreeItem extends vscode.TreeItem } refreshDocumentCount = async (): Promise => { + // Skip the count on views and time-series collections since it will error. + if ( + this._type === CollectionTypes.view || + this._type === CollectionTypes.timeseries + ) { + this.documentCount = null; + return 0; + } + try { // We fetch the document when we expand in order to show // the document count in the document list tree item `description`. this.documentCount = await this.getCount(); } catch (err) { - vscode.window.showInformationMessage( - `Unable to fetch document count: ${err}` - ); return 0; }