Skip to content

Commit fff3d91

Browse files
committed
copy the issue in the conversion
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
1 parent cfefc45 commit fff3d91

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

client/src/issue/issue.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ export function issueFromKeyAndValue(
3838
_key: string,
3939
value: ReadonlyJSONValue,
4040
): Issue {
41-
return issueSchema.parse(value);
41+
return {
42+
...issueSchema.parse(value),
43+
};
4244
}
4345

4446
export const COMMENT_KEY_PREFIX = `comment/`;

client/src/reducer.ts

+2
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ function diffReducer(state: State, diff: Diff): State {
152152
newFilteredIssues.splice(idx, 0, newIssue);
153153
}
154154
}
155+
155156
function del(key: string, oldValue: ReadonlyJSONValue) {
156157
const oldIssue = issueFromKeyAndValue(key, oldValue);
157158
const index = sortedIndexBy(newFilteredIssues, oldIssue, orderIteratee);
@@ -163,6 +164,7 @@ function diffReducer(state: State, diff: Diff): State {
163164
newFilteredIssues.splice(index, 1);
164165
}
165166
}
167+
166168
for (const diffOp of diff) {
167169
switch (diffOp.op) {
168170
case 'add': {

0 commit comments

Comments
 (0)