UI Page [Chats Prompt] (#20)

[+] fix(prompt.ts): add support for fetching prompts in Indonesian language
[+] fix(prompt.ts): update count of builtin prompts to include Indonesian prompts
This commit is contained in:
H0llyW00dzZ 2023-09-28 02:04:16 +07:00
parent 144200e315
commit fc4953f9a7
No known key found for this signature in database
GPG Key ID: 05C7FFFC0845C930

View File

@ -154,10 +154,13 @@ export const usePromptStore = createPersistStore(
fetch(PROMPT_URL)
.then((res) => res.json())
.then((res) => {
let fetchPrompts = [res.en, res.cn];
let fetchPrompts = [res.en, res.id, res.cn];
if (getLang() === "cn") {
fetchPrompts = fetchPrompts.reverse();
}
if (getLang() === "id") {
fetchPrompts = fetchPrompts.reverse();
}
const builtinPrompts = fetchPrompts.map((promptList: PromptList) => {
return promptList.map(
([title, content]) =>
@ -175,7 +178,8 @@ export const usePromptStore = createPersistStore(
const allPromptsForSearch = builtinPrompts
.reduce((pre, cur) => pre.concat(cur), [])
.filter((v) => !!v.title && !!v.content);
SearchService.count.builtin = res.en.length + res.cn.length;
SearchService.count.builtin =
res.en.length + res.id.length + res.cn.length;
SearchService.init(allPromptsForSearch, userPrompts);
});
},