From 16c16887ae2654803c9c62148e75e9a378babdea Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Sun, 14 Jul 2024 16:54:16 +0800 Subject: [PATCH 1/2] Improve prompt store lang sorting --- app/store/prompt.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/store/prompt.ts b/app/store/prompt.ts index a25cda581..92ff8b370 100644 --- a/app/store/prompt.ts +++ b/app/store/prompt.ts @@ -154,10 +154,10 @@ export const usePromptStore = createPersistStore( fetch(PROMPT_URL) .then((res) => res.json()) .then((res) => { - let fetchPrompts = [res.en, res.tw, res.cn]; - if (getLang() === "cn") { - fetchPrompts = fetchPrompts.reverse(); - } + const lang = getLang(); + const fetchPrompts = [res[lang], res.en, res.tw, res.cn].filter( + Boolean, + ); const builtinPrompts = fetchPrompts.map((promptList: PromptList) => { return promptList.map( ([title, content]) => From bc53c17a8c830feb458257e8f11e1097b3256528 Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Mon, 15 Jul 2024 00:54:25 +0800 Subject: [PATCH 2/2] Improve prompt store prompt list counting --- app/store/prompt.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/store/prompt.ts b/app/store/prompt.ts index 92ff8b370..dcbeebdfb 100644 --- a/app/store/prompt.ts +++ b/app/store/prompt.ts @@ -175,8 +175,9 @@ 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 + res.tw.length; + SearchService.count.builtin = Object.values(res) + .filter(Array.isArray) + .reduce((total, promptList) => total + promptList.length, 0); SearchService.init(allPromptsForSearch, userPrompts); }); },