mirror of
https://github.com/cudr/slate-collaborative.git
synced 2026-03-02 03:40:18 +00:00
feat: success garbage cursor
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user