feat: success garbage cursor

This commit is contained in:
cudr
2019-10-12 12:19:06 +03:00
parent 4efc8db60e
commit ad2780b936
3 changed files with 34 additions and 9 deletions

View File

@@ -124,6 +124,7 @@ class Connection {
socket.leave(id)
this.garbageCursor(socket.nsp.name, id)
this.garbageNsp()
}
@@ -137,6 +138,20 @@ class Connection {
})
}
garbageCursor = (nsp, id) => {
const doc = this.docSet.getDoc(nsp)
if (!doc.cursors) return
const change = Automerge.change(
doc,
`remove cursor ${id}`,
(d: any) => delete d.cursors[id]
)
this.docSet.setDoc(nsp, change)
}
removeDoc = async nsp => {
const doc = this.docSet.getDoc(nsp)