perf: Don't load CRDT state from database by default (#3215)

This commit is contained in:
Tom Moor
2022-03-09 20:07:10 -08:00
committed by GitHub
parent 5efeb90fdd
commit d399e1048a
6 changed files with 27 additions and 8 deletions

View File

@@ -15,7 +15,7 @@ export default async function documentUpdater({
ydoc: Y.Doc;
userId?: string;
}) {
const document = await Document.findByPk(documentId);
const document = await Document.scope("withState").findByPk(documentId);
invariant(document, "document not found");
const state = Y.encodeStateAsUpdate(ydoc);
@@ -34,7 +34,7 @@ export default async function documentUpdater({
const existingIds = document.collaboratorIds;
const collaboratorIds = uniq([...pudIds, ...existingIds]);
await Document.scope("withUnpublished").update(
await Document.scope(["withDrafts", "withState"]).update(
{
text,
state: Buffer.from(state),