mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-12 21:13:43 +08:00
better delete chat-list-item UX
This commit is contained in:
@@ -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>
|
||||
|
@@ -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
9148
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user