Skip to content

Commit

Permalink
fix: mysterious narrat save bug
Browse files Browse the repository at this point in the history
  • Loading branch information
liana-p committed Aug 18, 2024
1 parent 2dc6727 commit 6e06481
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/narrat/src/stores/vm-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const useVM = defineStore('vm', {
id: value.id,
};
} else {
return value;
return null;
}
}),
};
Expand Down
7 changes: 2 additions & 5 deletions packages/narrat/src/utils/data-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,9 @@ export function deepCopy<T>(a: T): T {
}

export function deepCopyMap<T>(a: T, predicate: (value: any) => any): T {
if (a === null) {
return null as any;
}
if (typeof a === 'object') {
const res = predicate(a);
if (predicate(a)) {
if (res) {
return res;
}
if (Array.isArray(a)) {
Expand All @@ -312,6 +309,6 @@ export function deepCopyMap<T>(a: T, predicate: (value: any) => any): T {
return b;
}
} else {
return predicate(a);
return a;
}
}

0 comments on commit 6e06481

Please sign in to comment.