Skip to content

Commit 9d6eb5c

Browse files
pyphiliakim
andauthored
feat: copy update on page copy (#1969)
* feat: copy update on page copy * refactor: apply pr requested changes --------- Co-authored-by: kim <kim.phanhoang@epfl.ch>
1 parent 9f34803 commit 9d6eb5c

7 files changed

Lines changed: 382 additions & 254 deletions

File tree

src/services/item/plugins/page/PagePersistence.ts

Lines changed: 0 additions & 102 deletions
This file was deleted.

src/services/item/plugins/page/WSDoc.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import * as syncProtocol from 'y-protocols/sync';
1616
import * as Y from 'yjs';
1717

1818
import { MESSAGE_AWARENESS_CODE, MESSAGE_SYNC_CODE } from './constants';
19+
import { PageItemService } from './page.service';
1920

2021
const wsReadyStateConnecting = 0;
2122
const wsReadyStateOpen = 1;
@@ -25,18 +26,21 @@ const wsReadyStateOpen = 1;
2526
* Broadcast updates to attached connections
2627
*/
2728
export class WSDoc extends Y.Doc {
28-
name: string;
29-
conns: Map<WebSocket, Set<number>>;
30-
enableAwareness: boolean;
31-
awareness: awarenessProtocol.Awareness;
29+
public awareness: awarenessProtocol.Awareness;
30+
public conns: Map<WebSocket, Set<number>>;
3231

33-
constructor(name: string, enableAwareness: boolean) {
32+
protected name: string;
33+
protected enableAwareness: boolean;
34+
protected pageItemService: PageItemService;
35+
36+
constructor(pageItemService: PageItemService, name: string, enableAwareness: boolean) {
3437
super();
3538
this.name = name;
3639
this.conns = new Map();
3740
this.enableAwareness = enableAwareness;
3841
this.awareness = new awarenessProtocol.Awareness(this);
3942
this.awareness.setLocalState(null);
43+
this.pageItemService = pageItemService;
4044
}
4145

4246
protected broadcastUpdate(update: Uint8Array) {

0 commit comments

Comments
 (0)