Skip to content

Commit

Permalink
fix: template name init bug
Browse files Browse the repository at this point in the history
  • Loading branch information
windingwind committed Sep 14, 2023
1 parent 609fdba commit ef79469
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/modules/template/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ function initTemplates() {
// Convert old template keys to new format
const raw = getPref("templateKeys") as string;
let keys = raw ? JSON.parse(raw) : [];
if (keys.length > 0 && typeof keys[0] !== "string") {
keys = keys.map((t: { name: string }) => t.name);
setTemplateKeys(keys);
if (keys.length > 0) {
keys = keys.map((t: { name: string } | string) => {
if (typeof t === "string") {
return t;
}
return t.name;
});
setTemplateKeys(Array.from(new Set(keys)));
}
// Add default templates
const templateKeys = getTemplateKeys();
Expand Down

0 comments on commit ef79469

Please sign in to comment.