mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-16 06:53:42 +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 />
|
<DeleteIcon />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -134,7 +134,6 @@ export const useChatStore = create<ChatStore>()(
|
|||||||
set((state) => {
|
set((state) => {
|
||||||
let nextIndex = state.currentSessionIndex;
|
let nextIndex = state.currentSessionIndex;
|
||||||
const sessions = state.sessions;
|
const sessions = state.sessions;
|
||||||
|
|
||||||
if (sessions.length === 1) {
|
if (sessions.length === 1) {
|
||||||
return {
|
return {
|
||||||
currentSessionIndex: 0,
|
currentSessionIndex: 0,
|
||||||
@@ -142,11 +141,13 @@ export const useChatStore = create<ChatStore>()(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
sessions.splice(index, 1);
|
|
||||||
|
|
||||||
if (nextIndex === index) {
|
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 {
|
return {
|
||||||
currentSessionIndex: nextIndex,
|
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