-
-
Save nichoth/35d3b55c728985ce7bc63920a04a0935 to your computer and use it in GitHub Desktop.
force sync jazz state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function forceSync(account: Account) { | |
const { syncManager } = account._raw.core.node; | |
const peer = Object.values(syncManager.peers)[0]; | |
if (!peer) { | |
throw new Error("no peer"); | |
} | |
const values = Object.values(account._raw.core.node.coValues).flatMap((x) => { | |
if ("coValue" in x.state) { | |
return [x.state.coValue]; | |
} | |
return []; | |
}); | |
await Promise.all(values.map((value) => syncManager.syncCoValue(value))); | |
await Promise.all( | |
values.map((value) => { | |
return syncManager.waitForUploadIntoPeer(peer.id, value.id); | |
}), | |
); | |
console.log("synced."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment