Skip to content

Commit 667e145

Browse files
committed
fix: onLoadDocument now accepts a yjs update (Uint8Array or Buffer) or a Y.Doc. fixes #795, #271
1 parent a247146 commit 667e145

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/server/src/Hocuspocus.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,10 @@ export class Hocuspocus<Context = any> {
380380
await this.hooks(
381381
"onLoadDocument",
382382
hookPayload,
383-
(loadedDocument: Doc | Uint8Array | undefined) => {
383+
(loadedDocument: Doc | Uint8ArrayConstructor | undefined) => {
384384
if (loadedDocument instanceof Doc) {
385385
applyUpdate(document, encodeStateAsUpdate(loadedDocument));
386-
} else if (Array.isArray(loadedDocument)) {
386+
} else if (loadedDocument instanceof Uint8Array) {
387387
applyUpdate(document, loadedDocument);
388388
}
389389
},

0 commit comments

Comments
 (0)