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.

chore(infra): remove compatible code (#6833)

EYHN8d8bd4960087
diff --git a/packages/common/infra/src/sync/doc/event.ts b/packages/common/infra/src/sync/doc/event.ts
index 4dc5bac438..d8e77209da 100644
--- a/packages/common/infra/src/sync/doc/event.ts
+++ b/packages/common/infra/src/sync/doc/event.ts
@@ -11,11 +11,6 @@ export type DocEvent =
docId: string;
update: Uint8Array;
clientId: string;
- }
- | {
- type: 'LegacyClientUpdateCommitted';
- docId: string;
- update: Uint8Array;
};
export interface DocEventBus {
diff --git a/packages/common/infra/src/sync/doc/local.ts b/packages/common/infra/src/sync/doc/local.ts
index 7eea53c7cd..560587db78 100644
--- a/packages/common/infra/src/sync/doc/local.ts
+++ b/packages/common/infra/src/sync/doc/local.ts
@@ -254,13 +254,6 @@ export class DocEngineLocalPart {
});
}
},
- LegacyClientUpdateCommitted: ({ docId, update }) => {
- this.schedule({
- type: 'save',
- docId,
- update,
- });
- },
};
handleDocUpdate = (update: Uint8Array, origin: any, doc: YDoc) => {
diff --git a/packages/frontend/core/src/modules/workspace-engine/impls/engine/doc-broadcast-channel.ts b/packages/frontend/core/src/modules/workspace-engine/impls/engine/doc-broadcast-channel.ts
index e04a9d9f3d..5f8c43e0ea 100644
--- a/packages/frontend/core/src/modules/workspace-engine/impls/engine/doc-broadcast-channel.ts
+++ b/packages/frontend/core/src/modules/workspace-engine/impls/engine/doc-broadcast-channel.ts
@@ -1,48 +1,9 @@
import type { DocEvent, DocEventBus } from '@toeverything/infra';
-type LegacyChannelMessage = {
- type: 'db-updated';
- payload: {
- docId: string;
- update: Uint8Array;
- };
- __from_new_doc_engine?: boolean;
-};
-
export class BroadcastChannelDocEventBus implements DocEventBus {
- legacyChannel = new BroadcastChannel('indexeddb:' + this.workspaceId);
senderChannel = new BroadcastChannel('doc:' + this.workspaceId);
- constructor(private readonly workspaceId: string) {
- this.legacyChannel.addEventListener(
- 'message',
- (event: MessageEvent<LegacyChannelMessage>) => {
- if (event.data.__from_new_doc_engine) {
- return;
- }
- if (event.data.type === 'db-updated') {
- this.emit({
- type: 'LegacyClientUpdateCommitted',
- docId: event.data.payload.docId,
- update: event.data.payload.update,
- });
- }
- }
- );
- }
+ constructor(private readonly workspaceId: string) {}
emit(event: DocEvent): void {
- if (
- event.type === 'ClientUpdateCommitted' ||
- event.type === 'ServerUpdateCommitted'
- ) {
- this.legacyChannel.postMessage({
- type: 'db-updated',
- payload: {
- docId: event.docId,
- update: event.update,
- },
- __from_new_doc_engine: true,
- } satisfies LegacyChannelMessage);
- }
this.senderChannel.postMessage(event);
}