Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 27 additions & 15 deletions extensions/ql-vscode/src/databases/db-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,21 @@ export class DbManager {
public async removeDbItem(dbItem: DbItem): Promise<void> {
await this.dbConfigStore.removeDbItem(dbItem);

// Updating the expanded items takes care of cleaning up
// any non-existent items.
await this.updateExpandedItems(this.getExpandedItems());
await this.removeDbItemFromExpandedState(dbItem);
}

public async updateDbItemExpandedState(
dbItem: DbItem,
itemExpanded: boolean,
): Promise<void> {
const currentExpandedItems = this.getExpandedItems();
public async removeDbItemFromExpandedState(dbItem: DbItem): Promise<void> {
// When collapsing or expanding a list we clean up the expanded state and remove
// all items that don't exist anymore.

const newExpandedItems = updateExpandedItem(
currentExpandedItems,
dbItem,
itemExpanded,
);
await this.updateDbItemExpandedState(dbItem, false);
}

await this.updateExpandedItems(newExpandedItems);
public async addDbItemToExpandedState(dbItem: DbItem): Promise<void> {
// When collapsing or expanding a list we clean up the expanded state and remove
// all items that don't exist anymore.

await this.updateDbItemExpandedState(dbItem, true);
}

public async addNewRemoteRepo(
Expand Down Expand Up @@ -142,7 +139,7 @@ export class DbManager {
newDbItem,
);

await this.updateExpandedItems(newExpandedItems);
await this.setExpandedItems(newExpandedItems);
}

public async renameLocalDb(
Expand Down Expand Up @@ -214,4 +211,19 @@ export class DbManager {

await this.setExpandedItems(itemsToStore);
}

private async updateDbItemExpandedState(
dbItem: DbItem,
itemExpanded: boolean,
): Promise<void> {
const currentExpandedItems = this.getExpandedItems();

const newExpandedItems = updateExpandedItem(
currentExpandedItems,
dbItem,
itemExpanded,
);

await this.updateExpandedItems(newExpandedItems);
}
}
4 changes: 2 additions & 2 deletions extensions/ql-vscode/src/databases/ui/db-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ export class DbPanel extends DisposableObject {
throw Error("Expected a database item.");
}

await this.dbManager.updateDbItemExpandedState(event.element.dbItem, false);
await this.dbManager.removeDbItemFromExpandedState(event.element.dbItem);
}

private async onDidExpandElement(
Expand All @@ -397,7 +397,7 @@ export class DbPanel extends DisposableObject {
throw Error("Expected a database item.");
}

await this.dbManager.updateDbItemExpandedState(event.element.dbItem, true);
await this.dbManager.addDbItemToExpandedState(event.element.dbItem);
}

/**
Expand Down