From 2055aba8472b94916b406d52e55986aba7457c23 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 16 Jan 2019 16:39:51 +0100 Subject: [PATCH] fix updating view --- .../components/plugin-manager-component.js | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/app/components/plugin-manager-component.js b/src/app/components/plugin-manager-component.js index bdd283ffef..66259820c4 100644 --- a/src/app/components/plugin-manager-component.js +++ b/src/app/components/plugin-manager-component.js @@ -31,8 +31,8 @@ class PluginManagerComponent { setStore (store) { this.store = store - this.store.event.on('activate', (name) => { this.views.items[name] ? this.views.items[name].querySelector('button').innerHTML = 'deactivate' : null }) - this.store.event.on('deactivate', (name) => { this.views.items[name] ? this.views.items[name].querySelector('button').innerHTML = 'activate' : null }) + this.store.event.on('activate', (name) => { this.reRender() }) + this.store.event.on('deactivate', (name) => { this.reRender() }) } render () { @@ -46,7 +46,7 @@ class PluginManagerComponent {

Inactive Modules

` - this.views.root = yo` + var rootView = yo`

Plugin Manager

@@ -69,12 +69,14 @@ class PluginManagerComponent { var modulesAll = this.store.getAll() modulesAll.sort() modulesAll.forEach((mod) => { - if ( !(modulesActive.includes(mod)) ) { + if (!modulesActive.includes(mod)) { this.views.inactiveMods.appendChild(this.renderItem(mod.profile.name)) } }) - - return this.views.root + if (!this.views.root) { + this.views.root = rootView + } + return rootView } renderItem (item) { @@ -82,13 +84,11 @@ class PluginManagerComponent { const mod = this.store.getOne(item) if (!mod) return - let action = async() => { + let action = () => { if (this.store.isActive(item)) { - await this.appManager.deactivateOne(item) - this.reRender() + this.appManager.deactivateOne(item) } else { - await this.appManager.activateOne(item) - this.reRender() + this.appManager.activateOne(item) } } @@ -103,14 +103,13 @@ class PluginManagerComponent { ${ctrBtns}
` - return this.views.items[item] } - reRender (item) { - document.getElementById('pluginManager').innerHTML = '' - let piMan = this.render() - document.getElementById('pluginManager').appendChild(piMan) + reRender () { + if (this.views.root) { + yo.update(this.views.root, this.render()) + } } }