Skip to content

Commit

Permalink
Improve JSON data handling
Browse files Browse the repository at this point in the history
  • Loading branch information
wtetsu committed Aug 19, 2020
1 parent 2346e62 commit 6ba8688
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/options/component/WholeSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export const WholeSettings: React.FC<Props> = (props) => {
return immer(orgSettings, (d) => {
const errors = [];
for (const key of Object.keys(d)) {
if (!(key in newSettings)) {
continue;
}
if (!canReplace(d[key], newSettings[key])) {
errors.push(`Invalid ${key}`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/options/logic/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const isShiftJisSoleChar = (byte: number) => {

export const preProcessSettings = (settings: MouseDictionarySettings): MouseDictionarySettings => {
return immer(settings, (d) => {
for (let i = 0; i < d.replaceRules.length; i++) {
for (let i = 0; i < d?.replaceRules?.length; i++) {
d.replaceRules[i].key = i.toString();
}
});
Expand Down

0 comments on commit 6ba8688

Please sign in to comment.