Revert "alvin request"

This commit is contained in:
alvin8313
2023-04-08 15:31:57 +08:00
committed by GitHub
parent 2cfe04656f
commit 7ff0bb97cf
15 changed files with 43 additions and 168 deletions

View File

@@ -332,19 +332,18 @@ export const useChatStore = create<ChatStore>()(
const isLastSession = get().sessions.length === 1;
if (!isMobileScreen() || confirm(Locale.Home.DeleteChat)) {
get().removeSession(index);
showToast(Locale.Home.DeleteToast, {
text: Locale.Home.Revert,
onClick() {
set((state) => ({
sessions: state.sessions
.slice(0, index)
.concat([deletedSession])
.concat(state.sessions.slice(index + Number(isLastSession))),
}));
},
});
}
showToast(Locale.Home.DeleteToast, {
text: Locale.Home.Revert,
onClick() {
set((state) => ({
sessions: state.sessions
.slice(0, index)
.concat([deletedSession])
.concat(state.sessions.slice(index + Number(isLastSession))),
}));
},
});
},
currentSession() {

View File

@@ -1,7 +1,6 @@
import { create } from "zustand";
import { persist } from "zustand/middleware";
import Fuse from "fuse.js";
import { getLang } from "../locales";
export interface Prompt {
id?: number;
@@ -26,13 +25,11 @@ export const SearchService = {
count: {
builtin: 0,
},
allBuiltInPrompts: [] as Prompt[],
init(prompts: Prompt[]) {
if (this.ready) {
return;
}
this.allBuiltInPrompts = prompts;
this.engine.setCollection(prompts);
this.ready = true;
},
@@ -81,11 +78,6 @@ export const usePromptStore = create<PromptStore>()(
},
search(text) {
if (text.length === 0) {
// return all prompts
const userPrompts = get().prompts?.values?.() ?? [];
return SearchService.allBuiltInPrompts.concat([...userPrompts]);
}
return SearchService.search(text) as Prompt[];
},
}),
@@ -100,11 +92,7 @@ export const usePromptStore = create<PromptStore>()(
fetch(PROMPT_URL)
.then((res) => res.json())
.then((res) => {
let fetchPrompts = [res.en, res.cn];
if (getLang() === "cn") {
fetchPrompts = fetchPrompts.reverse();
}
const builtinPrompts = fetchPrompts
const builtinPrompts = [res.en, res.cn]
.map((promptList: PromptList) => {
return promptList.map(
([title, content]) =>