Persist source view ID in ctx when using a view ID in the rows API and support collab in views

This commit is contained in:
Andrew Kingston 2023-08-17 12:07:37 +01:00
parent abc072cbbe
commit e7c4ebea39
2 changed files with 5 additions and 4 deletions

View File

@ -27,6 +27,7 @@ export default async (ctx: Ctx<Row>, next: Next) => {
} }
ctx.params.sourceId = tableId ctx.params.sourceId = tableId
ctx.params.viewId = viewId
return next() return next()
} }

View File

@ -80,8 +80,8 @@ export default class GridSocket extends BaseSocket {
} }
emitRowUpdate(ctx: any, row: Row) { emitRowUpdate(ctx: any, row: Row) {
const tableId = getTableId(ctx) const resourceId = ctx.params?.viewId || getTableId(ctx)
const room = `${ctx.appId}-${tableId}` const room = `${ctx.appId}-${resourceId}`
this.emitToRoom(ctx, room, GridSocketEvent.RowChange, { this.emitToRoom(ctx, room, GridSocketEvent.RowChange, {
id: row._id, id: row._id,
row, row,
@ -89,8 +89,8 @@ export default class GridSocket extends BaseSocket {
} }
emitRowDeletion(ctx: any, id: string) { emitRowDeletion(ctx: any, id: string) {
const tableId = getTableId(ctx) const resourceId = ctx.params?.viewId || getTableId(ctx)
const room = `${ctx.appId}-${tableId}` const room = `${ctx.appId}-${resourceId}`
this.emitToRoom(ctx, room, GridSocketEvent.RowChange, { id, row: null }) this.emitToRoom(ctx, room, GridSocketEvent.RowChange, { id, row: null })
} }