Skip to content

Commit

Permalink
Fix inversePatches applying order
Browse files Browse the repository at this point in the history
  • Loading branch information
shqld committed Sep 25, 2024
1 parent 40f9975 commit 3af40b9
Show file tree
Hide file tree
Showing 3 changed files with 207 additions and 133 deletions.
10 changes: 8 additions & 2 deletions src/patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ const ADDED = Symbol('ADDED');
function generateArrayPatches(
proxyState: ProxyDraft<Array<any>>,
basePath: any[],
patches: Patches,
inversePatches: Patches,
patches_: Patches,
inversePatches_: Patches,
pathAsArray: boolean
) {
let { original, arrayChanges } = proxyState;

const patches = [];
const inversePatches = [];

// console.log('generateArrayPatches', proxyState.key);

let copy = proxyState.copy!;
Expand Down Expand Up @@ -138,6 +141,9 @@ function generateArrayPatches(
});
}

patches_.push(...patches);
inversePatches_.unshift(...inversePatches);

// console.log('patches', [...patches]);
// console.log('inversePatches', [...inversePatches]);
}
Expand Down
Loading

0 comments on commit 3af40b9

Please sign in to comment.