fix: mutation latency in sidebar projects when user leaves the project (#2083)

* fix: mutation latency in sidebar projects when user leaves the project

* chore: remove console
This commit is contained in:
guru_sainath 2023-09-04 17:24:52 +05:30 committed by GitHub
parent 2c9c8d5a89
commit faf5a274cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,6 @@
import React from "react"; import React from "react";
// next imports // next imports
import { useRouter } from "next/router"; import { useRouter } from "next/router";
// swr
import { mutate } from "swr";
// react-hook-form // react-hook-form
import { Controller, useForm } from "react-hook-form"; import { Controller, useForm } from "react-hook-form";
// headless ui // headless ui
@ -21,6 +19,7 @@ import { RootStore } from "store/root";
// hooks // hooks
import useToast from "hooks/use-toast"; import useToast from "hooks/use-toast";
import useUser from "hooks/use-user"; import useUser from "hooks/use-user";
import useProjects from "hooks/use-projects";
// types // types
import { IProject } from "types"; import { IProject } from "types";
@ -42,6 +41,7 @@ export const ConfirmProjectLeaveModal: React.FC = observer(() => {
const { project } = store; const { project } = store;
const { user } = useUser(); const { user } = useUser();
const { mutateProjects } = useProjects();
const { setToastAlert } = useToast(); const { setToastAlert } = useToast();
@ -59,9 +59,6 @@ export const ConfirmProjectLeaveModal: React.FC = observer(() => {
reset({ ...defaultValues }); reset({ ...defaultValues });
}; };
project?.projectLeaveDetails &&
console.log("project leave confirmation modal", project?.projectLeaveDetails);
const onSubmit = async (data: any) => { const onSubmit = async (data: any) => {
if (data) { if (data) {
if (data.projectName === project?.projectLeaveDetails?.name) { if (data.projectName === project?.projectLeaveDetails?.name) {
@ -73,13 +70,7 @@ export const ConfirmProjectLeaveModal: React.FC = observer(() => {
user user
) )
.then((res) => { .then((res) => {
mutate<IProject[]>( mutateProjects();
PROJECTS_LIST(project.projectLeaveDetails.workspaceSlug.toString(), {
is_favorite: "all",
}),
(prevData) => prevData?.filter((project: IProject) => project.id !== data.id),
false
);
handleClose(); handleClose();
router.push(`/${workspaceSlug}/projects`); router.push(`/${workspaceSlug}/projects`);
}) })