Ensue table schema change made via grids are properly synced with backend stores, given absence of websocket events for own events

This commit is contained in:
Andrew Kingston 2023-06-02 15:28:48 +01:00
parent 2db3012ae0
commit 0582dd40b2
3 changed files with 6 additions and 3 deletions

View File

@ -37,6 +37,7 @@
allowDeleteRows={!isUsersTable}
schemaOverrides={isUsersTable ? userSchemaOverrides : null}
showAvatars={false}
on:updatetable={e => tables.replaceTable(id, e.detail)}
>
<svelte:fragment slot="controls">
{#if isInternal}

View File

@ -46,7 +46,7 @@ export const createStores = () => {
}
export const deriveStores = context => {
const { table, columns, stickyColumn, API } = context
const { table, columns, stickyColumn, API, dispatch } = context
// Updates the tables primary display column
const changePrimaryDisplay = async column => {
@ -90,6 +90,10 @@ export const deriveStores = context => {
// Update local state
table.set(newTable)
// Broadcast change to external state can be updated, as this change
// will not be received by the builder websocket because we caused it ourselves
dispatch("updatetable", newTable)
// Update server
await API.saveTable(newTable)
}

View File

@ -52,8 +52,6 @@ export const createWebsocket = (path, options = DefaultOptions) => {
socket.on(event, data => {
if (data?.apiSessionId !== APISessionID) {
callback(data)
} else {
console.log("ignore", event, data)
}
})
}