fix: clear local data after reset msgs

This commit is contained in:
Tristan Yang
2023-07-14 07:07:57 +08:00
parent d3b21ab11e
commit f7077c22b5
2 changed files with 14 additions and 2 deletions
@@ -7,6 +7,7 @@ import Modal from "@/components/Modal";
import Button from "@/components/styled/Button";
import StyledModal from "@/components/styled/Modal";
import { VisibleModalType } from "./index";
import useLogout from "@/hooks/useLogout";
interface Props {
context: VisibleModalType;
@@ -17,6 +18,7 @@ interface Props {
const ClearConfirmModal: FC<Props> = ({ context, title, desc, closeModal }) => {
// const { t } = useTranslation("auth");
const { clearLocalData } = useLogout();
const { t: ct } = useTranslation();
const [clearFiles, { isLoading: filesClearing, isSuccess: clearFilesSuccess }] =
useLazyClearAllFilesQuery();
@@ -42,6 +44,13 @@ const ClearConfirmModal: FC<Props> = ({ context, title, desc, closeModal }) => {
closeModal();
}
}, [clearSuccess]);
// 即时清除本地数据
useEffect(() => {
if (clearMsgSuccess) {
clearLocalData(false);
}
}, [clearMsgSuccess]);
const clearing = msgClearing || filesClearing;
return (
<Modal id="modal-modal">