Skip to content

Commit

Permalink
Merge pull request #9 from badsyntax/tree-refresh
Browse files Browse the repository at this point in the history
Fix refresh migrations
  • Loading branch information
badsyntax authored Dec 23, 2022
2 parents 0f72c4b + 909cd39 commit 78fd146
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 75 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"entity",
"framework",
"migrations",
"entity framework",
".net",
"dotnet",
"core",
Expand Down
24 changes: 20 additions & 4 deletions src/actions/AddMigrationAction.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import * as vscode from 'vscode';
import { CommandProvider } from '../commands/CommandProvider';
import { RefreshTreeCommand } from '../commands/RefreshTreeCommand';
import { getCommandsConfig } from '../config/config';

import type { TerminalProvider } from '../terminal/TerminalProvider';
import {
dbContextsCache,
DbContextTreeItem,
} from '../treeView/DbContextTreeItem';
import { TerminalAction } from './TerminalAction';

export class AddMigrationAction extends TerminalAction {
constructor(
terminalProvider: TerminalProvider,
workspaceRoot: string,
dbContext: string,
project: string,
private readonly workspaceRoot: string,
private readonly dbContext: string,
private readonly project: string,
) {
super(
terminalProvider,
Expand All @@ -31,9 +37,19 @@ export class AddMigrationAction extends TerminalAction {
if (!migrationName) {
return;
}
return super.run({
await super.run({
...this.params,
migrationName,
});
const cacheId = DbContextTreeItem.getCacheId(
this.workspaceRoot,
this.project,
this.dbContext,
);
dbContextsCache.clear(cacheId);
await vscode.commands.executeCommand(
CommandProvider.getCommandName(RefreshTreeCommand.commandName),
false,
);
}
}
27 changes: 24 additions & 3 deletions src/actions/RemoveMigrationAction.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import * as vscode from 'vscode';
import { CommandProvider } from '../commands/CommandProvider';
import { RefreshTreeCommand } from '../commands/RefreshTreeCommand';
import { getCommandsConfig } from '../config/config';
import type { TerminalProvider } from '../terminal/TerminalProvider';
import {
dbContextsCache,
DbContextTreeItem,
} from '../treeView/DbContextTreeItem';
import { TerminalAction } from './TerminalAction';

export class RemoveMigrationAction extends TerminalAction {
constructor(
terminalProvider: TerminalProvider,
workspaceRoot: string,
dbContext: string,
project: string,
private readonly workspaceRoot: string,
private readonly dbContext: string,
private readonly project: string,
) {
super(
terminalProvider,
Expand All @@ -19,4 +26,18 @@ export class RemoveMigrationAction extends TerminalAction {
workspaceRoot,
);
}

public async run() {
await super.run();
const cacheId = DbContextTreeItem.getCacheId(
this.workspaceRoot,
this.project,
this.dbContext,
);
dbContextsCache.clear(cacheId);
await vscode.commands.executeCommand(
CommandProvider.getCommandName(RefreshTreeCommand.commandName),
false,
);
}
}
6 changes: 0 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type * as vscode from 'vscode';
import { TreeDataProvider } from './treeView/TreeDataProvider';
import { CommandProvider } from './commands/CommandProvider';
import { MigrationTreeItemDecorationProvider } from './treeView/MigrationTreeItemDecorationProvider';
import { DbContextModelSnapshotWatcher } from './util/DbContextModelSnapshotWatcher';
import { SolutionFinder } from './solution/SolutionProvider';
import { Terminal } from './terminal/Terminal';
import { TerminalProvider } from './terminal/TerminalProvider';
Expand All @@ -12,9 +11,6 @@ const subscriptions: vscode.Disposable[] = [];

export async function activate(_context: vscode.ExtensionContext) {
const solutionFiles = await SolutionFinder.getSolutionFiles();
const dbContextModelContextWatcher = new DbContextModelSnapshotWatcher(
solutionFiles,
);
const migrationTreeItemDecorationProvider =
new MigrationTreeItemDecorationProvider();
const treeDataProvider = new TreeDataProvider(solutionFiles);
Expand All @@ -23,9 +19,7 @@ export async function activate(_context: vscode.ExtensionContext) {
treeDataProvider,
terminalProvider,
);

subscriptions.push(
dbContextModelContextWatcher,
migrationTreeItemDecorationProvider,
treeDataProvider,
commandProvider,
Expand Down
62 changes: 0 additions & 62 deletions src/util/DbContextModelSnapshotWatcher.ts

This file was deleted.

0 comments on commit 78fd146

Please sign in to comment.