Skip to content

Commit

Permalink
fix: Cannot read properties of undefined (reading 'filter')
Browse files Browse the repository at this point in the history
see #58
  • Loading branch information
Mara-Li committed Dec 13, 2022
1 parent 9e90eaa commit 3cb5760
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions plugin/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,18 @@ export async function convertOldSettings(
oldSettings === "" ? [] : oldSettings.split(/[,\n]\W*/);
await plugin.saveSettings();
}
// @ts-ignore
settings[settingsToConvert] = settings[settingsToConvert].filter(
(e: string) => e !== ""
);
await plugin.saveSettings();
try {
// @ts-ignore
settings[settingsToConvert] = settings[settingsToConvert].filter(
(e: string) => e !== ""
);
await plugin.saveSettings();
} catch (e) {
//if the error is settings[settingsToConvert] is undefined meaning the settings doesn't exist yet
// @ts-ignore
settings[settingsToConvert] = [];
await plugin.saveSettings();
}
}

/**
Expand Down

0 comments on commit 3cb5760

Please sign in to comment.