Spring cleaning before review.
This commit is contained in:
parent
70f39b6b6b
commit
007e919d0e
|
@ -169,8 +169,8 @@ 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, processInternalTable(table), {
|
||||
includeSelf: true,
|
||||
builderSocket?.emitTableUpdate(ctx, table, {
|
||||
includeOriginator: true,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -87,6 +87,10 @@ export function isExternalTable(tableId: string) {
|
|||
return tableId.includes(DocumentType.DATASOURCE)
|
||||
}
|
||||
|
||||
export function isInternalTable(tableId: string) {
|
||||
return !isExternalTable(tableId)
|
||||
}
|
||||
|
||||
export function buildExternalTableId(datasourceId: string, tableName: string) {
|
||||
// encode spaces
|
||||
if (tableName.includes(" ")) {
|
||||
|
|
|
@ -16,6 +16,8 @@ import { gridSocket } from "./index"
|
|||
import { clearLock, updateLock } from "../utilities/redis"
|
||||
import { Socket } from "socket.io"
|
||||
import { BuilderSocketEvent } from "@budibase/shared-core"
|
||||
import { processInternalTable } from "../sdk/app/tables/getters"
|
||||
import { isExternalTable, isInternalTable } from "../integrations/utils"
|
||||
|
||||
export default class BuilderSocket extends BaseSocket {
|
||||
constructor(app: Koa, server: http.Server) {
|
||||
|
@ -101,6 +103,13 @@ export default class BuilderSocket extends BaseSocket {
|
|||
}
|
||||
|
||||
emitTableUpdate(ctx: any, table: Table, options?: EmitOptions) {
|
||||
// This was added to make sure that sourceId is always present when
|
||||
// sending this message to clients. Without this, tables without a
|
||||
// sourceId (e.g. ta_users) won't get correctly updated client-side.
|
||||
if (isInternalTable(table._id!)) {
|
||||
table = processInternalTable(table)
|
||||
}
|
||||
|
||||
this.emitToRoom(
|
||||
ctx,
|
||||
ctx.appId,
|
||||
|
|
|
@ -13,8 +13,10 @@ import { createContext, runMiddlewares } from "./middleware"
|
|||
|
||||
export interface EmitOptions {
|
||||
// Whether to include the originator of the request from the broadcast,
|
||||
// defaults to false.
|
||||
includeSelf?: boolean
|
||||
// defaults to false because it is assumed that the user who triggered
|
||||
// an action will already have the changes of that action reflected in their
|
||||
// own UI, so there is no need to send them again.
|
||||
includeOriginator?: boolean
|
||||
}
|
||||
|
||||
const anonUser = () => ({
|
||||
|
@ -284,7 +286,7 @@ export class BaseSocket {
|
|||
options?: EmitOptions
|
||||
) {
|
||||
let emitPayload = { ...payload }
|
||||
if (!options?.includeSelf) {
|
||||
if (!options?.includeOriginator) {
|
||||
emitPayload.apiSessionId = ctx.headers?.[Header.SESSION_ID]
|
||||
}
|
||||
this.io.in(room).emit(event, emitPayload)
|
||||
|
|
Loading…
Reference in New Issue