Refactor loading state in Home.vue

This commit is contained in:
Gabriel Pastori 2023-11-17 16:55:45 -03:00
parent 75d01cba39
commit c59893ad21

View File

@ -26,11 +26,7 @@
<v-row dense> <v-row dense>
<v-col cols="12" v-if="instances.length === 0 || loading"> <v-col cols="12" v-if="instances.length === 0 || loading">
<v-progress-linear <v-progress-linear v-if="loading" indeterminate color="info" />
v-if="loading"
indeterminate
color="info"
></v-progress-linear>
<v-alert type="info" class="mb-4" v-else :loading="loading" outlined> <v-alert type="info" class="mb-4" v-else :loading="loading" outlined>
{{ loading ? "Carregando..." : "Nenhuma instância encontrada" }} {{ loading ? "Carregando..." : "Nenhuma instância encontrada" }}
</v-alert> </v-alert>
@ -122,7 +118,7 @@ export default {
}, },
data: () => ({ data: () => ({
AppStore: useAppStore(), AppStore: useAppStore(),
loading: false, loadingInner: false,
loadingDelete: false, loadingDelete: false,
error: false, error: false,
statusMapper: statusMapper, statusMapper: statusMapper,
@ -163,17 +159,22 @@ export default {
}, },
async getInstances() { async getInstances() {
try { try {
this.loading = true; this.loadingInner = true;
this.instances = await this.AppStore.reconnect(); this.instances = await this.AppStore.reconnect();
} catch (e) { } catch (e) {
this.error = e.message?.message || e.message || e; this.error = e.message?.message || e.message || e;
} finally { } finally {
this.loading = false; this.loadingInner = false;
} }
}, },
}, },
watch: {}, watch: {},
computed: { computed: {
loading() {
debugger;
return this.loadingInner || this.AppStore.connecting;
},
instances() { instances() {
return this.AppStore.instances; return this.AppStore.instances;
}, },