diff --git a/src/options/App.vue b/src/options/App.vue
index e0452ad..3ea8e60 100644
--- a/src/options/App.vue
+++ b/src/options/App.vue
@@ -4,11 +4,11 @@
-
-
-
-
-
+
+
+
+
+
Select an option from the menu
@@ -53,6 +53,10 @@ export default {
this.selectedHostOption = hostOption;
},
+ async reload() {
+ this.hosts = await this.getHosts();
+ },
+
async addHost(form) {
if (!this.isHostFormValid(form)) {
this.notify('Invalid device parameter values', 'Device configuration error');
@@ -71,8 +75,8 @@ export default {
this.hosts[host.name] = host;
await this.saveHosts(this.hosts);
- this.selectedHost = Object.keys(this.hosts)[Object.keys(this.hosts).length - 1];
- this.isAddHost = false;
+ await this.reload();
+ this.select('host', Object.keys(this.hosts)[Object.keys(this.hosts).length - 1]);
} finally {
this.loading = false;
}
@@ -104,14 +108,16 @@ export default {
try {
const i = this.selectedHost;
- if (Object.keys(this.hosts).length <= 1) {
+ delete this.hosts[i];
+ await this.saveHosts(this.hosts);
+
+ if (!Object.keys(this.hosts).length) {
this.selectedHost = null;
} else {
this.selectedHost = Object.keys(this.hosts)[0];
}
- delete this.hosts[i];
- await this.saveHosts(this.hosts);
+ await this.reload();
} finally {
this.loading = false;
}
@@ -119,10 +125,7 @@ export default {
},
created() {
- const self = this;
- this.getHosts().then(hosts => {
- self.hosts = hosts;
- });
+ this.reload();
},
};
diff --git a/src/options/Config.vue b/src/options/Config.vue
index 7030511..de18007 100644
--- a/src/options/Config.vue
+++ b/src/options/Config.vue
@@ -21,7 +21,7 @@