fix: prompt import

This commit is contained in:
Timothy Jaeryang Baek 2024-12-24 15:32:23 -07:00
parent 364d6eb9c4
commit e1a198f0a3
2 changed files with 10 additions and 7 deletions

View File

@ -4,7 +4,7 @@ type PromptItem = {
command: string; command: string;
title: string; title: string;
content: string; content: string;
access_control: null | object; access_control?: null | object;
}; };
export const createNewPrompt = async (token: string, prompt: PromptItem) => { export const createNewPrompt = async (token: string, prompt: PromptItem) => {

View File

@ -239,12 +239,12 @@
console.log(savedPrompts); console.log(savedPrompts);
for (const prompt of savedPrompts) { for (const prompt of savedPrompts) {
await createNewPrompt( await createNewPrompt(localStorage.token, {
localStorage.token, command:
prompt.command.charAt(0) === '/' ? prompt.command.slice(1) : prompt.command, prompt.command.charAt(0) === '/' ? prompt.command.slice(1) : prompt.command,
prompt.title, title: prompt.title,
prompt.content content: prompt.content
).catch((error) => { }).catch((error) => {
toast.error(error); toast.error(error);
return null; return null;
}); });
@ -252,6 +252,9 @@
prompts = await getPromptList(localStorage.token); prompts = await getPromptList(localStorage.token);
await _prompts.set(await getPrompts(localStorage.token)); await _prompts.set(await getPrompts(localStorage.token));
importFiles = [];
promptsImportInputElement.value = '';
}; };
reader.readAsText(importFiles[0]); reader.readAsText(importFiles[0]);