Skip to content

Commit 506cdbc

Browse files
committed
feat: clear session only
1 parent c93a46a commit 506cdbc

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

app/components/settings.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ function SettingItem(props: {
4646

4747
export function Settings(props: { closeSettings: () => void }) {
4848
const [showEmojiPicker, setShowEmojiPicker] = useState(false);
49-
const [config, updateConfig, resetConfig, clearAllData] = useChatStore(
50-
(state) => [
49+
const [config, updateConfig, resetConfig, clearAllData, clearSessions] =
50+
useChatStore((state) => [
5151
state.config,
5252
state.updateConfig,
5353
state.resetConfig,
5454
state.clearAllData,
55-
]
56-
);
55+
state.clearSessions,
56+
]);
5757

5858
const updateStore = useUpdateStore();
5959
const [checkingUpdate, setCheckingUpdate] = useState(false);
@@ -93,7 +93,7 @@ export function Settings(props: { closeSettings: () => void }) {
9393
<div className={styles["window-action-button"]}>
9494
<IconButton
9595
icon={<ClearIcon />}
96-
onClick={clearAllData}
96+
onClick={clearSessions}
9797
bordered
9898
title={Locale.Settings.Actions.ClearAll}
9999
/>

app/store/app.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ interface ChatStore {
177177
config: ChatConfig;
178178
sessions: ChatSession[];
179179
currentSessionIndex: number;
180+
clearSessions: () => void;
180181
removeSession: (index: number) => void;
181182
selectSession: (index: number) => void;
182183
newSession: () => void;
@@ -211,6 +212,13 @@ export const useChatStore = create<ChatStore>()(
211212
...DEFAULT_CONFIG,
212213
},
213214

215+
clearSessions(){
216+
set(() => ({
217+
sessions: [createEmptySession()],
218+
currentSessionIndex: 0,
219+
}));
220+
},
221+
214222
resetConfig() {
215223
set(() => ({ config: { ...DEFAULT_CONFIG } }));
216224
},

0 commit comments

Comments
 (0)