Update websocket user metadata structures

This commit is contained in:
Andrew Kingston 2023-07-03 11:23:08 +01:00
parent d80cca9a11
commit 4725faf8b5
3 changed files with 17 additions and 2 deletions

View File

@ -30,8 +30,9 @@ export const deriveStores = context => {
([$users, $focusedCellId]) => { ([$users, $focusedCellId]) => {
let map = {} let map = {}
$users.forEach(user => { $users.forEach(user => {
if (user.focusedCellId && user.focusedCellId !== $focusedCellId) { const cellId = user.gridMetadata?.focusedCellId
map[user.focusedCellId] = user if (cellId && cellId !== $focusedCellId) {
map[cellId] = user
} }
}) })
return map return map

View File

@ -78,6 +78,13 @@ export default class BuilderSocket extends BaseSocket {
} }
} }
async updateUser(socket: Socket, patch: Object) {
await super.updateUser(socket, {
...socket.data.builderMetadata,
...patch,
})
}
emitTableUpdate(ctx: any, table: Table) { emitTableUpdate(ctx: any, table: Table) {
this.emitToRoom(ctx, ctx.appId, BuilderSocketEvent.TableChange, { this.emitToRoom(ctx, ctx.appId, BuilderSocketEvent.TableChange, {
id: table._id, id: table._id,

View File

@ -69,6 +69,13 @@ export default class GridSocket extends BaseSocket {
}) })
} }
async updateUser(socket: Socket, patch: Object) {
await super.updateUser(socket, {
...socket.data.gridMetadata,
...patch,
})
}
emitRowUpdate(ctx: any, row: Row) { emitRowUpdate(ctx: any, row: Row) {
const tableId = getTableId(ctx) const tableId = getTableId(ctx)
const room = `${ctx.appId}-${tableId}` const room = `${ctx.appId}-${tableId}`