mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Don't strip seed
This commit is contained in:
parent
9f8c87ae8c
commit
e72d83541a
3 changed files with 1019 additions and 985 deletions
|
@ -804,10 +804,8 @@ export class AppStateChange implements Change<AppState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CFDO: consider adding here (nonnullable) version & versionNonce & updated & seed (so that we have correct versions when recunstructing from remote)
|
// CFDO: consider adding here (nonnullable) version & versionNonce & updated & seed (so that we have correct versions when recunstructing from remote)
|
||||||
type ElementPartial<T extends ExcalidrawElement = ExcalidrawElement> = Omit<
|
type ElementPartial<T extends ExcalidrawElement = ExcalidrawElement> =
|
||||||
ElementUpdate<Ordered<T>>,
|
ElementUpdate<Ordered<T>>;
|
||||||
"seed"
|
|
||||||
>;
|
|
||||||
|
|
||||||
type ElementsChangeOptions = {
|
type ElementsChangeOptions = {
|
||||||
shouldRedistribute: boolean;
|
shouldRedistribute: boolean;
|
||||||
|
@ -1605,8 +1603,7 @@ export class ElementsChange implements Change<SceneElementsMap> {
|
||||||
private static stripIrrelevantProps(
|
private static stripIrrelevantProps(
|
||||||
partial: Partial<OrderedExcalidrawElement>,
|
partial: Partial<OrderedExcalidrawElement>,
|
||||||
): ElementPartial {
|
): ElementPartial {
|
||||||
const { id, updated, version, versionNonce, seed, ...strippedPartial } =
|
const { id, updated, version, versionNonce, ...strippedPartial } = partial;
|
||||||
partial;
|
|
||||||
|
|
||||||
return strippedPartial;
|
return strippedPartial;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -64,8 +64,45 @@ const checkpoint = (name: string) => {
|
||||||
...strippedAppState
|
...strippedAppState
|
||||||
} = h.state;
|
} = h.state;
|
||||||
expect(strippedAppState).toMatchSnapshot(`[${name}] appState`);
|
expect(strippedAppState).toMatchSnapshot(`[${name}] appState`);
|
||||||
expect(h.history.undoStack).toMatchSnapshot(`[${name}] undo stack`);
|
|
||||||
expect(h.history.redoStack).toMatchSnapshot(`[${name}] redo stack`);
|
const stripSeed = (deltas: Record<string, { deleted: any; inserted: any }>) =>
|
||||||
|
Object.entries(deltas).reduce((acc, curr) => {
|
||||||
|
const { inserted, deleted, ...rest } = curr[1];
|
||||||
|
|
||||||
|
delete inserted.seed;
|
||||||
|
delete deleted.seed;
|
||||||
|
|
||||||
|
acc[curr[0]] = {
|
||||||
|
inserted,
|
||||||
|
deleted,
|
||||||
|
...rest,
|
||||||
|
};
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, {} as Record<string, any>);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
h.history.undoStack.map((x) => ({
|
||||||
|
...x,
|
||||||
|
elementsChange: {
|
||||||
|
...x.elementsChange,
|
||||||
|
added: stripSeed(x.elementsChange.added),
|
||||||
|
removed: stripSeed(x.elementsChange.updated),
|
||||||
|
updated: stripSeed(x.elementsChange.removed),
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
).toMatchSnapshot(`[${name}] undo stack`);
|
||||||
|
expect(
|
||||||
|
h.history.redoStack.map((x) => ({
|
||||||
|
...x,
|
||||||
|
elementsChange: {
|
||||||
|
...x.elementsChange,
|
||||||
|
added: stripSeed(x.elementsChange.added),
|
||||||
|
removed: stripSeed(x.elementsChange.updated),
|
||||||
|
updated: stripSeed(x.elementsChange.removed),
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
).toMatchSnapshot(`[${name}] redo stack`);
|
||||||
expect(h.elements.length).toMatchSnapshot(`[${name}] number of elements`);
|
expect(h.elements.length).toMatchSnapshot(`[${name}] number of elements`);
|
||||||
h.elements
|
h.elements
|
||||||
.map(({ seed, versionNonce, ...strippedElement }) => strippedElement)
|
.map(({ seed, versionNonce, ...strippedElement }) => strippedElement)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue