Skip to content

Commit

Permalink
fix: ChatGPTNextWeb#3174 should prompt to confirm to delete chat
Browse files Browse the repository at this point in the history
(cherry picked from commit fbc0236)
  • Loading branch information
Yidadaa authored and Endlessworld committed Nov 16, 2023
1 parent 20e1641 commit 9671d3c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 8 additions & 2 deletions app/components/chat-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { MaskAvatar } from "./mask";
import { Mask } from "../store/mask";
import { useEffect, useRef } from "react";
import { showConfirm } from "./ui-lib";
import { useMobileScreen } from "../utils";

export function ChatItem(props: {
onClick?: () => void;
Expand Down Expand Up @@ -84,7 +85,11 @@ export function ChatItem(props: {

<div
className={styles["chat-item-delete"]}
onClickCapture={props.onDelete}
onClickCapture={(e) => {
props.onDelete?.();
e.preventDefault();
e.stopPropagation();
}}
>
<DeleteIcon />
</div>
Expand All @@ -105,6 +110,7 @@ export function ChatList(props: { narrow?: boolean }) {
);
const chatStore = useChatStore();
const navigate = useNavigate();
const isMobileScreen = useMobileScreen();

const onDragEnd: OnDragEndResponder = (result) => {
const { destination, source } = result;
Expand Down Expand Up @@ -146,7 +152,7 @@ export function ChatList(props: { narrow?: boolean }) {
}}
onDelete={async () => {
if (
!props.narrow ||
(!props.narrow && !isMobileScreen) ||
(await showConfirm(Locale.Home.DeleteChat))
) {
chatStore.deleteSession(i);
Expand Down
5 changes: 3 additions & 2 deletions app/components/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { useEffect, useRef, useCallback, useMemo } from "react";
import { useEffect, useRef, useMemo } from "react";

import styles from "./home.module.scss";

import { IconButton } from "./button";
import SettingsIcon from "../icons/settings.svg";
import ChatGptIcon from "../icons/chatgpt.svg";
import CloseIcon from "../icons/close.svg";
import DeleteIcon from "../icons/delete.svg";
import MaskIcon from "../icons/mask.svg";
import AnnouncementIcon from "../icons/announcement.svg";
import UserIcon from "../icons/user.svg";
Expand Down Expand Up @@ -211,7 +212,7 @@ export function SideBar(props: { className?: string }) {
<IconButton
shadow
text={Locale.Chat.Actions.Delete}
icon={<CloseIcon />}
icon={<DeleteIcon />}
onClick={async () => {
if (await showConfirm(Locale.Home.DeleteChat)) {
chatStore.deleteSession(chatStore.currentSessionIndex);
Expand Down

0 comments on commit 9671d3c

Please sign in to comment.