Skip to content

Commit

Permalink
copy the issue in the conversion
Browse files Browse the repository at this point in the history
still investigating.

Problem I'm seeing:
- objects are mutated out from under me by Replicache. Object with ID 1 gets mutated to Object with ID 2 and vice-versa.

Potential causes:
- my cvr updates
- replicache upgrade
  • Loading branch information
tantaman committed Dec 8, 2023
1 parent cfefc45 commit fff3d91
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion client/src/issue/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export function issueFromKeyAndValue(
_key: string,
value: ReadonlyJSONValue,
): Issue {
return issueSchema.parse(value);
return {
...issueSchema.parse(value),
};
}

export const COMMENT_KEY_PREFIX = `comment/`;
Expand Down
2 changes: 2 additions & 0 deletions client/src/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ function diffReducer(state: State, diff: Diff): State {
newFilteredIssues.splice(idx, 0, newIssue);
}
}

function del(key: string, oldValue: ReadonlyJSONValue) {
const oldIssue = issueFromKeyAndValue(key, oldValue);
const index = sortedIndexBy(newFilteredIssues, oldIssue, orderIteratee);
Expand All @@ -163,6 +164,7 @@ function diffReducer(state: State, diff: Diff): State {
newFilteredIssues.splice(index, 1);
}
}

for (const diffOp of diff) {
switch (diffOp.op) {
case 'add': {
Expand Down

0 comments on commit fff3d91

Please sign in to comment.