fix(realtime): use number[] for transport but ArrayBuffer for database

Co-authored-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
Erik Michelson 2025-05-19 11:37:22 +02:00
parent 21a1f35281
commit 4869f3310c
No known key found for this signature in database
GPG key ID: DB99ADDDC5C0AF82
9 changed files with 37 additions and 28 deletions

View file

@ -31,7 +31,7 @@ export class RealtimeNoteStore {
const realtimeNote = new RealtimeNote(
noteId,
initialTextContent,
initialYjsState,
initialYjsState ? Array.from(new Uint8Array(initialYjsState)) : undefined,
);
realtimeNote.on('destroy', () => {
this.noteIdToRealtimeNote.delete(noteId);

View file

@ -49,7 +49,7 @@ export class RealtimeNoteService implements BeforeApplicationShutdown {
realtimeNote.getRealtimeDoc().getCurrentContent(),
false,
undefined,
realtimeNote.getRealtimeDoc().encodeStateAsUpdate(),
new Uint8Array(realtimeNote.getRealtimeDoc().encodeStateAsUpdate()),
)
.then(() => {
realtimeNote.announceMetadataUpdate();

View file

@ -34,7 +34,7 @@ export class RealtimeNote extends EventEmitter2<RealtimeNoteEventMap> {
constructor(
private readonly noteId: number,
initialTextContent: string,
initialYjsState?: ArrayBuffer,
initialYjsState?: number[],
) {
super();
this.logger = new Logger(`${RealtimeNote.name} ${noteId}`);