mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 19:59:02 +08:00
fix: retrieve awareness states after reconnect
This commit is contained in:
parent
e46c4a85ff
commit
12d994275c
@ -49,8 +49,8 @@ const CollaborationCursor = Extension.create({
|
||||
*/
|
||||
user: (attributes: { [key: string]: any }): Command => () => {
|
||||
this.options.user = attributes
|
||||
|
||||
this.options.provider.awareness.setLocalStateField('user', this.options.user)
|
||||
this.options.onUpdate(awarenessStatesToArray(this.options.provider.awareness.states))
|
||||
|
||||
return true
|
||||
},
|
||||
@ -66,6 +66,19 @@ const CollaborationCursor = Extension.create({
|
||||
this.options.onUpdate(awarenessStatesToArray(this.options.provider.awareness.states))
|
||||
})
|
||||
|
||||
this.options.provider.awareness.on('update', () => {
|
||||
this.options.onUpdate(awarenessStatesToArray(this.options.provider.awareness.states))
|
||||
})
|
||||
|
||||
this.options.provider.on('status', (event: { status: string }) => {
|
||||
if (event.status === 'connected') {
|
||||
// FIX: Reset the awareness state
|
||||
// PR: https://github.com/yjs/y-protocols/issues/7
|
||||
this.options.provider.awareness.setLocalState({})
|
||||
this.options.provider.awareness.setLocalStateField('user', this.options.user)
|
||||
}
|
||||
})
|
||||
|
||||
this.options.onUpdate(awarenessStatesToArray(this.options.provider.awareness.states))
|
||||
|
||||
return this.options.provider.awareness
|
||||
|
Loading…
Reference in New Issue
Block a user