Last active
November 19, 2024 15:29
-
-
Save Schniz/d9c78c898d502ef101df373bb450e7a2 to your computer and use it in GitHub Desktop.
force sync jazz state
This file contains 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