From 71dc4938da32de47f76770769e697712a4b69e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Tue, 30 Mar 2021 11:32:01 +0200 Subject: [PATCH] adds an init method to the tables store --- packages/builder/src/builderStore/store/frontend.js | 10 ++-------- packages/builder/src/stores/backend/tables.js | 10 +++++++++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 9db23d3001..219c4f3626 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -69,20 +69,14 @@ export const getFrontendStore = () => { // Initialise backend stores const [ _integrations, - _tables, ] = await Promise.all([ - api.get("/api/integrations").then(r => r.json()), - api.get(`/api/tables`).then(r => r.json()), + api.get("/api/integrations").then(r => r.json()) ]) datasources.init() integrations.set(_integrations) queries.init() database.set(application.instance) - tables.set({ - list: _tables, - selected: {}, - draft: {}, - }) + tables.init() }, routing: { fetch: async () => { diff --git a/packages/builder/src/stores/backend/tables.js b/packages/builder/src/stores/backend/tables.js index c13a3d46ce..0992f04f23 100644 --- a/packages/builder/src/stores/backend/tables.js +++ b/packages/builder/src/stores/backend/tables.js @@ -71,10 +71,18 @@ export function createTablesStore() { return { subscribe, - set, fetch, select, save, + init: async () => { + const response = await api.get("/api/tables") + const json = await response.json() + set({ + list: json, + selected: {}, + draft: {}, + }) + }, delete: async table => { await api.delete(`/api/tables/${table._id}/${table._rev}`) update(state => ({