fix: throttle fractional indices validation (#8306)

This commit is contained in:
Marcel Mraz
2024-08-02 11:55:15 +02:00
committed by GitHub
parent e63dd025c9
commit 84d89b9a8a
4 changed files with 71 additions and 40 deletions

View File

@@ -37,10 +37,12 @@ export const validateFractionalIndices = (
{
shouldThrow = false,
includeBoundTextValidation = false,
ignoreLogs,
reconciliationContext,
}: {
shouldThrow: boolean;
includeBoundTextValidation: boolean;
ignoreLogs?: true;
reconciliationContext?: {
localElements: ReadonlyArray<ExcalidrawElement>;
remoteElements: ReadonlyArray<ExcalidrawElement>;
@@ -95,13 +97,15 @@ export const validateFractionalIndices = (
);
}
// report just once and with the stacktrace
console.error(
errorMessages.join("\n\n"),
error.stack,
elements.map((x) => stringifyElement(x)),
...additionalContext,
);
if (!ignoreLogs) {
// report just once and with the stacktrace
console.error(
errorMessages.join("\n\n"),
error.stack,
elements.map((x) => stringifyElement(x)),
...additionalContext,
);
}
if (shouldThrow) {
// if enabled, gather all the errors first, throw once
@@ -157,7 +161,11 @@ export const syncMovedIndices = (
validateFractionalIndices(
elementsCandidates,
// we don't autofix invalid bound text indices, hence don't include it in the validation
{ includeBoundTextValidation: false, shouldThrow: true },
{
includeBoundTextValidation: false,
shouldThrow: true,
ignoreLogs: true,
},
);
// split mutation so we don't end up in an incosistent state