Skip to content

Commit

Permalink
fix(vscode): also show loading bar in Common Nx Commands view (#2308)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKless authored Nov 13, 2024
1 parent 6709217 commit 7141dbc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
7 changes: 6 additions & 1 deletion libs/vscode/nx-commands-view/src/lib/nx-commands-provider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { GlobalConfigurationStore } from '@nx-console/vscode/configuration';
import { onWorkspaceRefreshed } from '@nx-console/vscode/lsp-client';
import {
getNxlsClient,
onWorkspaceRefreshed,
} from '@nx-console/vscode/lsp-client';
import { getNxWorkspace } from '@nx-console/vscode/nx-workspace';
import { AbstractTreeProvider } from '@nx-console/vscode/utils';
import { commands, ExtensionContext } from 'vscode';
Expand All @@ -14,6 +17,8 @@ export class NxCommandsTreeProvider extends AbstractTreeProvider<NxCommandsTreeI
);

onWorkspaceRefreshed(() => this.refresh());

getNxlsClient().showRefreshLoadingAtLocation({ viewId: 'nxCommands' });
}

getParent(_: NxCommandsTreeItem) {
Expand Down
32 changes: 3 additions & 29 deletions libs/vscode/nx-project-view/src/lib/init-nx-project-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export function initNxProjectView(

AtomizerDecorationProvider.register(context);

listenToLoadingEventsAndShowBar(context);
context.subscriptions.push(
getNxlsClient().showRefreshLoadingAtLocation({ viewId: 'nxProjects' })
);

return nxProjectsTreeProvider;
}
Expand Down Expand Up @@ -61,31 +63,3 @@ export async function showProjectConfiguration(selection: NxTreeItem) {
const target = viewItem.nxTarget;
return revealNxProject(project, root, target);
}

function listenToLoadingEventsAndShowBar(context: ExtensionContext) {
const client = getNxlsClient();
context.subscriptions.push(
client.onNotification(NxWorkspaceRefreshStartedNotification, () => {
const refreshPromise = new Promise<void>((resolve) => {
const disposable = client.onNotification(
NxWorkspaceRefreshNotification,
() => {
disposable?.dispose();
resolve();
}
);
});

window.withProgress(
{
location: { viewId: 'nxProjects' },
cancellable: false,
title: 'Refreshing Nx workspace',
},
async () => {
await refreshPromise;
}
);
})
);
}

0 comments on commit 7141dbc

Please sign in to comment.