better delete chat-list-item UX

This commit is contained in:
zZOMZz
2023-04-29 01:23:04 +08:00
parent b0cd8579f1
commit c09698d1f0
4 changed files with 9895 additions and 779 deletions

View File

@@ -134,7 +134,6 @@ export const useChatStore = create<ChatStore>()(
set((state) => {
let nextIndex = state.currentSessionIndex;
const sessions = state.sessions;
if (sessions.length === 1) {
return {
currentSessionIndex: 0,
@@ -142,11 +141,13 @@ export const useChatStore = create<ChatStore>()(
};
}
sessions.splice(index, 1);
if (nextIndex === index) {
nextIndex -= 1;
nextIndex =
nextIndex === sessions.length - 1 ? nextIndex - 1 : nextIndex;
} else {
nextIndex = nextIndex > index ? nextIndex - 1 : nextIndex;
}
sessions.splice(index, 1);
return {
currentSessionIndex: nextIndex,