mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-19 08:51:24 +00:00
Fix resource tree refresh issue (#222)
This commit is contained in:
@@ -290,6 +290,10 @@ export default class Database implements ViewModels.Database {
|
||||
}
|
||||
|
||||
private deleteCollectionsFromList(collectionsToRemove: Collection[]): void {
|
||||
if (collectionsToRemove.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const collectionsToKeep: Collection[] = [];
|
||||
|
||||
ko.utils.arrayForEach(this.collections(), (collection: Collection) => {
|
||||
|
||||
@@ -64,7 +64,7 @@ export class ResourceTreeAdapter implements ReactAdapter {
|
||||
|
||||
this.container.nonSystemDatabases.subscribe((databases: ViewModels.Database[]) => {
|
||||
// Clean up old databases
|
||||
this.cleanupDatabasesKoSubs(databases.map((database: ViewModels.Database) => database.id()));
|
||||
this.cleanupDatabasesKoSubs();
|
||||
|
||||
databases.forEach((database: ViewModels.Database) => this.watchDatabase(database));
|
||||
this.triggerRender();
|
||||
@@ -799,16 +799,10 @@ export class ResourceTreeAdapter implements ReactAdapter {
|
||||
this.koSubsCollectionIdMap.push(collectionId, sub);
|
||||
}
|
||||
|
||||
private cleanupDatabasesKoSubs(existingDatabaseIds: string[]): void {
|
||||
const databaseIdsToRemove = this.databaseCollectionIdMap
|
||||
.keys()
|
||||
.filter((id: string) => existingDatabaseIds.indexOf(id) === -1);
|
||||
|
||||
databaseIdsToRemove.forEach((databaseId: string) => {
|
||||
if (this.koSubsDatabaseIdMap.has(databaseId)) {
|
||||
this.koSubsDatabaseIdMap.get(databaseId).forEach((sub: ko.Subscription) => sub.dispose());
|
||||
this.koSubsDatabaseIdMap.delete(databaseId);
|
||||
}
|
||||
private cleanupDatabasesKoSubs(): void {
|
||||
this.koSubsDatabaseIdMap.keys().forEach((databaseId: string) => {
|
||||
this.koSubsDatabaseIdMap.get(databaseId).forEach((sub: ko.Subscription) => sub.dispose());
|
||||
this.koSubsDatabaseIdMap.delete(databaseId);
|
||||
|
||||
if (this.databaseCollectionIdMap.has(databaseId)) {
|
||||
this.databaseCollectionIdMap
|
||||
|
||||
Reference in New Issue
Block a user