Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(store-sync): sync to RECS #1197

Merged
merged 13 commits into from
Jul 31, 2023
3 changes: 2 additions & 1 deletion packages/store-sync/src/recs/syncToRecs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export async function syncToRecs<
const componentList = Object.values(components);

const numRecords = initialState.tables.reduce((sum, table) => sum + table.records.length, 0);
const recordsPerSyncProgressUpdate = Math.floor(numRecords / 100);
let recordsProcessed = 0;

for (const table of initialState.tables) {
Expand All @@ -115,7 +116,7 @@ export async function syncToRecs<
setComponent(component, entity, record.value as ComponentValue);

recordsProcessed++;
if (recordsProcessed % 1000 === 0) {
if (recordsProcessed % recordsPerSyncProgressUpdate === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

setComponent(components.SyncProgress, singletonEntity, {
step: SyncStep.SNAPSHOT,
message: `Hydrating from snapshot to block ${initialState.blockNumber}`,
Expand Down