Prevent errors when user has no projects

This commit is contained in:
alexweininger 2021-04-30 01:50:46 -07:00
parent 7ace94ffdc
commit c8ec8b6a63
2 changed files with 10 additions and 1 deletions

View file

@ -32,6 +32,11 @@ export class HealthTreeItemProvider implements vscode.TreeDataProvider<vscode.Tr
}
async getChildren(element?: HealthTreeItem): Promise<vscode.TreeItem[]> {
if (healthClient === undefined) {
return [];
}
// get children for root
if (element === undefined) {
const health = await healthClient.checkup();

View file

@ -20,9 +20,13 @@ export class StorageTreeItemProvider implements vscode.TreeDataProvider<vscode.T
}
async getChildren(element?: vscode.TreeItem): Promise<vscode.TreeItem[]> {
if (storageClient === undefined) {
return [];
}
const files = await storageClient.listFiles();
if (files === undefined || files?.files.length === 0) {
const noStorage = new vscode.TreeItem('No files found');
const noStorage = new vscode.TreeItem("No files found");
return [noStorage];
}
return files.files.map((file) => new FileTreeItem(file));