1
0
Fork 0
mirror of synced 2024-10-04 03:54:37 +13:00

Fix missing sourceId on Table sent to the websocket.

This commit is contained in:
Sam Rose 2023-10-25 14:41:23 +01:00
parent 52f97fbd1f
commit 70f39b6b6b
No known key found for this signature in database
3 changed files with 13 additions and 5 deletions

View file

@ -47,6 +47,7 @@ export const createBuilderWebsocket = appId => {
// Data section events
socket.onOther(BuilderSocketEvent.TableChange, ({ id, table }) => {
console.log("Table change", id, table)
tables.replaceTable(id, table)
})
socket.onOther(BuilderSocketEvent.DatasourceChange, ({ id, datasource }) => {

View file

@ -24,6 +24,7 @@ import sdk from "../../../sdk"
import { jsonFromCsvString } from "../../../utilities/csv"
import { builderSocket } from "../../../websockets"
import { cloneDeep, isEqual } from "lodash"
import { processInternalTable } from "../../../sdk/app/tables/getters"
function pickApi({ tableId, table }: { tableId?: string; table?: Table }) {
if (table && !tableId) {
@ -168,7 +169,9 @@ export async function migrate(ctx: UserCtx<MigrateRequest, MigrateResponse>) {
let result = await sdk.tables.migrate(table, oldColumn, newColumn)
for (let table of result.tablesUpdated) {
builderSocket?.emitTableUpdate(ctx, table, { includeSelf: true })
builderSocket?.emitTableUpdate(ctx, processInternalTable(table), {
includeSelf: true,
})
}
ctx.status = 200

View file

@ -20,11 +20,15 @@ import datasources from "../datasources"
import sdk from "../../../sdk"
function processInternalTables(docs: AllDocsResponse<Table[]>): Table[] {
return docs.rows.map((tableDoc: any) => ({
...tableDoc.doc,
return docs.rows.map(tableDoc => processInternalTable(tableDoc.doc))
}
export function processInternalTable(table: Table): Table {
return {
...table,
type: "internal",
sourceId: tableDoc.doc.sourceId || BudibaseInternalDB._id,
}))
sourceId: table.sourceId || BudibaseInternalDB._id,
}
}
export async function getAllInternalTables(db?: Database): Promise<Table[]> {