fix(realtime): allow realtime user status updates from users that have read-only access

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-05-08 17:23:28 +02:00
parent 46330563fa
commit d29e840bc6
4 changed files with 276 additions and 56 deletions

View file

@ -20,12 +20,19 @@ export class ReceiveRemoteCursorViewPlugin implements PluginValue {
this.listener = messageTransporter.on(
MessageType.REALTIME_USER_STATE_SET,
({ payload }) => {
const cursors: RemoteCursor[] = payload.users.map((user) => ({
from: user.cursor.from,
to: user.cursor.to,
displayName: user.displayName,
styleIndex: user.styleIndex
}))
const cursors = payload.users
.map((user) => {
if (!user.cursor) {
return undefined
}
return {
from: user.cursor.from,
to: user.cursor.to,
displayName: user.displayName,
styleIndex: user.styleIndex
}
})
.filter((value) => value !== undefined) as RemoteCursor[]
view.dispatch({
effects: [remoteCursorUpdateEffect.of(cursors)]
})