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

@@ -67,7 +67,13 @@ export function ChatItem(props: {
</>
)}
<div className={styles["chat-item-delete"]} onClick={props.onDelete}>
<div
className={styles["chat-item-delete"]}
onClick={(e) => {
e.stopPropagation();
props.onDelete?.();
}}
>
<DeleteIcon />
</div>
</div>

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,

9148
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

1509
yarn.lock

File diff suppressed because it is too large Load Diff