fix: AwarenessChangeEvent type
This commit is contained in:
@@ -107,13 +107,11 @@ function MultiplayerEditor({ onSynced, ...props }: Props, ref: any) {
|
||||
presence.updateFromAwarenessChangeEvent(documentId, event);
|
||||
|
||||
event.states.forEach(({ user, scrollY }) => {
|
||||
if (user) {
|
||||
if (scrollY !== undefined && user.id === ui.observingUserId) {
|
||||
window.scrollTo({
|
||||
top: scrollY * window.innerHeight,
|
||||
behavior: "smooth",
|
||||
});
|
||||
}
|
||||
if (scrollY !== undefined && user?.id === ui.observingUserId) {
|
||||
window.scrollTo({
|
||||
top: scrollY * window.innerHeight,
|
||||
behavior: "smooth",
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -38,8 +38,10 @@ export default class PresenceStore {
|
||||
|
||||
event.states.forEach((state) => {
|
||||
const { user, cursor } = state;
|
||||
this.update(documentId, user.id, !!cursor);
|
||||
existingUserIds = existingUserIds.filter((id) => id !== user.id);
|
||||
if (user) {
|
||||
this.update(documentId, user.id, !!cursor);
|
||||
existingUserIds = existingUserIds.filter((id) => id !== user.id);
|
||||
}
|
||||
});
|
||||
|
||||
existingUserIds.forEach((userId) => {
|
||||
|
||||
@@ -204,5 +204,5 @@ export type WebsocketEvent =
|
||||
| WebsocketEntitiesEvent;
|
||||
|
||||
export type AwarenessChangeEvent = {
|
||||
states: { user: { id: string }; cursor: any; scrollY: number | undefined }[];
|
||||
states: { user?: { id: string }; cursor: any; scrollY: number | undefined }[];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user