fix: template name init bug
This commit is contained in:
parent
609fdba2de
commit
ef79469863
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue