Fix destory (#48)

* Fix destory

* In case disconnect when the doc is not loaded
This commit is contained in:
Ulion 2021-01-15 21:13:12 +08:00 committed by GitHub
parent 24dca9a49c
commit d141da4430
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -149,6 +149,10 @@ export const AutomergeEditor = {
garbageCursor: (e: AutomergeEditor, docId: string) => {
const doc = e.docSet.getDoc(docId)
if (!doc) {
return
}
const changed = Automerge.change<SyncDoc>(doc, (d: any) => {
delete d.cursors
})

View File

@ -122,6 +122,8 @@ const withSocketIO = <T extends AutomergeEditor>(
*/
e.destroy = () => {
e.socket.removeListener('disconnect')
e.socket.close()
e.closeConnection()