Fix missing sourceId on Table sent to the websocket.
This commit is contained in:
parent
52f97fbd1f
commit
70f39b6b6b
|
@ -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 }) => {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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[]> {
|
||||
|
|
Loading…
Reference in New Issue