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