Replace subscriptions in resource tree with useDatabases hook (#904)

This commit is contained in:
victor-meng
2021-06-23 11:45:29 -07:00
committed by GitHub
parent b392bed1b0
commit 738a02a0f3
6 changed files with 16 additions and 122 deletions

View File

@@ -175,6 +175,19 @@ export default class Collection implements ViewModels.Collection {
});
this.children = ko.observableArray<ViewModels.TreeNode>([]);
this.children.subscribe(() => {
// update the database in zustand store
const database = this.getDatabase();
database.collections(
database.collections()?.map((collection) => {
if (collection.id() === this.id()) {
return this;
}
return collection;
})
);
useDatabases.getState().updateDatabase(database);
});
this.storedProcedures = ko.computed(() => {
return this.children()