Skip to content

Commit

Permalink
fix(tree-explorer): dont show message when cannot fetch estimated count
Browse files Browse the repository at this point in the history
  • Loading branch information
Anemy authored Jul 7, 2021
1 parent f2868c6 commit 0211938
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/explorer/collectionTreeItem.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from 'vscode';
const path = require('path');
import path from 'path';

import { createLogger } from '../logging';
import DocumentListTreeItem, {
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -333,14 +333,20 @@ export default class CollectionTreeItem extends vscode.TreeItem
}

refreshDocumentCount = async (): Promise<number> => {
// 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;
}

Expand Down

0 comments on commit 0211938

Please sign in to comment.