fix: Fix broken state from an invalid folderId in the path (#8790)

* Fix the invalid folderId path

* log fix
This commit is contained in:
Mike Fortman 2025-07-01 07:15:32 -05:00 committed by GitHub
commit 7d44121691
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 2 deletions

View file

@ -84,8 +84,7 @@ function NoteNode({
),
[data, bgColor, selected],
);
console.log(nodeData);
console.log();
return (
<>
<NodeResizer

View file

@ -8,6 +8,7 @@ import {
ENABLE_DATASTAX_LANGFLOW,
ENABLE_MCP,
} from "@/customization/feature-flags";
import { useCustomNavigate } from "@/customization/hooks/use-custom-navigate";
import useFlowsManagerStore from "@/stores/flowsManagerStore";
import { useFolderStore } from "@/stores/foldersStore";
import { FlowType } from "@/types/flow";
@ -30,6 +31,7 @@ const HomePage = ({ type }: { type: "flows" | "components" | "mcp" }) => {
const [pageIndex, setPageIndex] = useState(1);
const [pageSize, setPageSize] = useState(12);
const [search, setSearch] = useState("");
const navigate = useCustomNavigate();
const [flowType, setFlowType] = useState<"flows" | "components" | "mcp">(
type,
@ -42,6 +44,18 @@ const HomePage = ({ type }: { type: "flows" | "components" | "mcp" }) => {
"";
const flows = useFlowsManagerStore((state) => state.flows);
useEffect(() => {
// Only check if we have a folderId and folders have loaded
if (folderId && folders && folders.length > 0) {
const folderExists = folders.find((folder) => folder.id === folderId);
if (!folderExists) {
// Folder doesn't exist for this user, redirect to /all
console.error("Invalid folderId, redirecting to /all");
navigate("/all");
}
}
}, [folderId, folders, navigate]);
const { data: folderData, isLoading } = useGetFolderQuery({
id: folderId ?? myCollectionId!,
page: pageIndex,