From e7c4ebea39eefcba85d60f3a8ce7d3e1d7070194 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 17 Aug 2023 12:07:37 +0100 Subject: [PATCH] Persist source view ID in ctx when using a view ID in the rows API and support collab in views --- packages/server/src/middleware/trimViewRowInfo.ts | 1 + packages/server/src/websockets/grid.ts | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/server/src/middleware/trimViewRowInfo.ts b/packages/server/src/middleware/trimViewRowInfo.ts index cedcb31640..6a7448262b 100644 --- a/packages/server/src/middleware/trimViewRowInfo.ts +++ b/packages/server/src/middleware/trimViewRowInfo.ts @@ -27,6 +27,7 @@ export default async (ctx: Ctx, next: Next) => { } ctx.params.sourceId = tableId + ctx.params.viewId = viewId return next() } diff --git a/packages/server/src/websockets/grid.ts b/packages/server/src/websockets/grid.ts index cf0faa0ec1..abc1872b56 100644 --- a/packages/server/src/websockets/grid.ts +++ b/packages/server/src/websockets/grid.ts @@ -80,8 +80,8 @@ export default class GridSocket extends BaseSocket { } emitRowUpdate(ctx: any, row: Row) { - const tableId = getTableId(ctx) - const room = `${ctx.appId}-${tableId}` + const resourceId = ctx.params?.viewId || getTableId(ctx) + const room = `${ctx.appId}-${resourceId}` this.emitToRoom(ctx, room, GridSocketEvent.RowChange, { id: row._id, row, @@ -89,8 +89,8 @@ export default class GridSocket extends BaseSocket { } emitRowDeletion(ctx: any, id: string) { - const tableId = getTableId(ctx) - const room = `${ctx.appId}-${tableId}` + const resourceId = ctx.params?.viewId || getTableId(ctx) + const room = `${ctx.appId}-${resourceId}` this.emitToRoom(ctx, room, GridSocketEvent.RowChange, { id, row: null }) }