Use individual functions for add and remove from expanded state
This commit is contained in:
@@ -78,24 +78,15 @@ 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> {
|
||||
await this.updateDbItemExpandedState(dbItem, false);
|
||||
}
|
||||
|
||||
const newExpandedItems = updateExpandedItem(
|
||||
currentExpandedItems,
|
||||
dbItem,
|
||||
itemExpanded,
|
||||
);
|
||||
|
||||
await this.updateExpandedItems(newExpandedItems);
|
||||
public async addDbItemToExpandedState(dbItem: DbItem): Promise<void> {
|
||||
await this.updateDbItemExpandedState(dbItem, true);
|
||||
}
|
||||
|
||||
public async addNewRemoteRepo(
|
||||
@@ -214,4 +205,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user