fix: usePatchUpdateFlow to conditionally refetch queries based on the browser URL (#3915)
* fix usePatchUpdateFlow to conditionally refetch queries based on the browser URL, preventing unecessary request * [autofix.ci] apply automated fixes * Refactor PageComponent to remove unnecessary query using useQueryClient * Refactor usePatchUpdateFlow to conditionally refetch queries based on the browser URL * [autofix.ci] apply automated fixes * Refactor PageComponent to remove unnecessary query using useQueryClient * Implement query cache cleanup on MainPage unmount * fix spelling --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
f906059a72
commit
5dec9cca9b
2 changed files with 9 additions and 3 deletions
|
|
@ -8,7 +8,6 @@ import { track } from "@/customization/utils/analytics";
|
||||||
import useAutoSaveFlow from "@/hooks/flows/use-autosave-flow";
|
import useAutoSaveFlow from "@/hooks/flows/use-autosave-flow";
|
||||||
import useUploadFlow from "@/hooks/flows/use-upload-flow";
|
import useUploadFlow from "@/hooks/flows/use-upload-flow";
|
||||||
import { getNodeRenderType, isSupportedNodeTypes } from "@/utils/utils";
|
import { getNodeRenderType, isSupportedNodeTypes } from "@/utils/utils";
|
||||||
|
|
||||||
import _, { cloneDeep } from "lodash";
|
import _, { cloneDeep } from "lodash";
|
||||||
import {
|
import {
|
||||||
KeyboardEvent,
|
KeyboardEvent,
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ import { useDeleteFolders } from "@/controllers/API/queries/folders";
|
||||||
import { useCustomNavigate } from "@/customization/hooks/use-custom-navigate";
|
import { useCustomNavigate } from "@/customization/hooks/use-custom-navigate";
|
||||||
import { track } from "@/customization/utils/analytics";
|
import { track } from "@/customization/utils/analytics";
|
||||||
import useAlertStore from "@/stores/alertStore";
|
import useAlertStore from "@/stores/alertStore";
|
||||||
import { useIsFetching } from "@tanstack/react-query";
|
import { useIsFetching, useQueryClient } from "@tanstack/react-query";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Outlet, useLocation } from "react-router-dom";
|
import { Outlet, useLocation } from "react-router-dom";
|
||||||
import DropdownButton from "../../../../components/dropdownButtonComponent";
|
import DropdownButton from "../../../../components/dropdownButtonComponent";
|
||||||
import PageLayout from "../../../../components/pageLayout";
|
import PageLayout from "../../../../components/pageLayout";
|
||||||
|
|
@ -28,6 +28,13 @@ export default function HomePage(): JSX.Element {
|
||||||
const setSuccessData = useAlertStore((state) => state.setSuccessData);
|
const setSuccessData = useAlertStore((state) => state.setSuccessData);
|
||||||
const setErrorData = useAlertStore((state) => state.setErrorData);
|
const setErrorData = useAlertStore((state) => state.setErrorData);
|
||||||
const folderToEdit = useFolderStore((state) => state.folderToEdit);
|
const folderToEdit = useFolderStore((state) => state.folderToEdit);
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
// cleanup the query cache when the component unmounts
|
||||||
|
// prevent unnecessary queries on flow update
|
||||||
|
useEffect(() => {
|
||||||
|
return () => queryClient.removeQueries({ queryKey: ["useGetFolder"] });
|
||||||
|
}, []);
|
||||||
|
|
||||||
const dropdownOptions = useDropdownOptions({
|
const dropdownOptions = useDropdownOptions({
|
||||||
navigate,
|
navigate,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue