fix: Cannot read properties of undefined (reading 'id')

This commit is contained in:
Tom Moor
2023-09-20 20:27:50 -04:00
parent 67b1fe5514
commit 5aa7b42f8b
6 changed files with 45 additions and 18 deletions

View File

@@ -7,6 +7,7 @@ import { Minute } from "@shared/utils/time";
import Logger from "@server/logging/Logger";
import { trace } from "@server/logging/tracing";
import { View } from "@server/models";
import { withContext } from "./types";
@trace()
export class ViewsExtension implements Extension {
@@ -21,7 +22,15 @@ export class ViewsExtension implements Extension {
*
* @param data The change payload
*/
async onChange({ documentName, context, socketId }: onChangePayload) {
async onChange({
documentName,
context,
socketId,
}: withContext<onChangePayload>) {
if (!context.user) {
return;
}
const lastUpdate = this.lastViewBySocket.get(socketId);
const [, documentId] = documentName.split(".");