Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

feat: add disconnect ws

MingLiang Wangbd5f0ad7c189
diff --git a/packages/data-center/src/provider/affine/affine.ts b/packages/data-center/src/provider/affine/affine.ts
index d86c42f9fa..41f438d88f 100644
--- a/packages/data-center/src/provider/affine/affine.ts
+++ b/packages/data-center/src/provider/affine/affine.ts
@@ -78,6 +78,12 @@ export class AffineProvider extends BaseProvider {
ws = new WebsocketProvider('/', room, doc);
this._wsMap.set(room, ws);
}
+ // close all websocket links
+ Array.from(this._wsMap.entries()).forEach(([id, ws]) => {
+ if (id !== room) {
+ ws.disconnect();
+ }
+ });
ws.connect();
await new Promise<void>((resolve, reject) => {
// TODO: synced will also be triggered on reconnection after losing sync