refactor: save ydoc state in the database, so it can be restored easier

By storing the ydoc state in the database we can reconnect lost clients easier
and enable offline editing because we continue using the crdt data that has been
used by the client before the connection loss.

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-03-24 10:26:49 +01:00
parent 4707540237
commit a826677225
26 changed files with 301 additions and 204 deletions

View file

@ -41,8 +41,10 @@ export class RealtimeConnection {
this.transporter.on('disconnected', () => {
realtimeNote.removeClient(this);
});
this.yDocSyncAdapter = new YDocSyncServerAdapter(this.transporter);
this.yDocSyncAdapter.setYDoc(realtimeNote.getRealtimeDoc());
this.yDocSyncAdapter = new YDocSyncServerAdapter(
this.transporter,
realtimeNote.getRealtimeDoc(),
);
this.realtimeUserStateAdapter = new RealtimeUserStatusAdapter(
this.user?.username ?? null,
this.getDisplayName(),