Update builder socket to ignore own events, and ensure table creation updates state without depending on the websocket
This commit is contained in:
parent
dab3263569
commit
53f1a4e67d
|
@ -15,25 +15,23 @@ export const createBuilderWebsocket = appId => {
|
||||||
socket.on("connect_error", err => {
|
socket.on("connect_error", err => {
|
||||||
console.log("Failed to connect to builder websocket:", err.message)
|
console.log("Failed to connect to builder websocket:", err.message)
|
||||||
})
|
})
|
||||||
|
|
||||||
// User events
|
|
||||||
socket.on(SocketEvent.UserUpdate, userStore.actions.updateUser)
|
|
||||||
socket.on(SocketEvent.UserDisconnect, userStore.actions.removeUser)
|
|
||||||
|
|
||||||
// Table events
|
|
||||||
socket.on(BuilderSocketEvent.TableChange, ({ id, table }) => {
|
|
||||||
tables.replaceTable(id, table)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Datasource events
|
|
||||||
socket.on(BuilderSocketEvent.DatasourceChange, ({ id, datasource }) => {
|
|
||||||
datasources.replaceDatasource(id, datasource)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Clean up user store on disconnect
|
|
||||||
socket.on("disconnect", () => {
|
socket.on("disconnect", () => {
|
||||||
userStore.actions.reset()
|
userStore.actions.reset()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// User events
|
||||||
|
socket.onOther(SocketEvent.UserUpdate, userStore.actions.updateUser)
|
||||||
|
socket.onOther(SocketEvent.UserDisconnect, userStore.actions.removeUser)
|
||||||
|
|
||||||
|
// Table events
|
||||||
|
socket.onOther(BuilderSocketEvent.TableChange, ({ id, table }) => {
|
||||||
|
tables.replaceTable(id, table)
|
||||||
|
})
|
||||||
|
|
||||||
|
// Datasource events
|
||||||
|
socket.onOther(BuilderSocketEvent.DatasourceChange, ({ id, datasource }) => {
|
||||||
|
datasources.replaceDatasource(id, datasource)
|
||||||
|
})
|
||||||
|
|
||||||
return socket
|
return socket
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ export function createTablesStore() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const savedTable = await API.saveTable(updatedTable)
|
const savedTable = await API.saveTable(updatedTable)
|
||||||
replaceTable(table._id, savedTable)
|
replaceTable(savedTable._id, savedTable)
|
||||||
await datasources.fetch()
|
await datasources.fetch()
|
||||||
select(savedTable._id)
|
select(savedTable._id)
|
||||||
return savedTable
|
return savedTable
|
||||||
|
|
Loading…
Reference in New Issue