Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

Fix: Unnecessary 400 requests

Ashish Viradiya94490e0e3c90
diff --git a/lib/swr/use-dataroom.ts b/lib/swr/use-dataroom.ts
index 6c52d988..9fce0ee0 100644
--- a/lib/swr/use-dataroom.ts
+++ b/lib/swr/use-dataroom.ts
@@ -245,7 +245,7 @@ export function useDataroomFolderWithParents({
const { data: folders, error } = useSWR<{ name: string; path: string }[]>(
teamId &&
- name &&
+ name && !!name.length &&
`/api/teams/${teamId}/datarooms/${dataroomId}/folders/parents/${name.join("/")}`,
fetcher,
{
diff --git a/lib/swr/use-folders.ts b/lib/swr/use-folders.ts
index 6fae53f1..329e5593 100644
--- a/lib/swr/use-folders.ts
+++ b/lib/swr/use-folders.ts
@@ -20,7 +20,7 @@ export function useFolderWithParents({ name }: { name: string[] }) {
const { data: folders, error } = useSWR<{ name: string; path: string }[]>(
teamInfo?.currentTeam?.id &&
- name &&
+ name && !!name.length &&
`/api/teams/${teamInfo?.currentTeam?.id}/folders/parents/${name.join("/")}`,
fetcher,
{