mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
6c70d3854a
* safley enable swr and make sure to minimalize re renders * resolve build errors * fix dropdowns updation by adding observer
50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
import useSWR from "swr";
|
|
import { useCycle, useEstimate, useLabel, useModule, useProjectState } from "./store";
|
|
|
|
export const useWorkspaceIssueProperties = (workspaceSlug: string | string[] | undefined) => {
|
|
const { fetchWorkspaceLabels } = useLabel();
|
|
|
|
const { fetchWorkspaceStates } = useProjectState();
|
|
|
|
const { fetchWorkspaceEstimates } = useEstimate();
|
|
|
|
const { fetchWorkspaceModules } = useModule();
|
|
|
|
const { fetchWorkspaceCycles } = useCycle();
|
|
|
|
// fetch workspace Modules
|
|
useSWR(
|
|
workspaceSlug ? `WORKSPACE_MODULES_${workspaceSlug}` : null,
|
|
workspaceSlug ? () => fetchWorkspaceModules(workspaceSlug.toString()) : null,
|
|
{ revalidateIfStale: false, revalidateOnFocus: false }
|
|
);
|
|
|
|
// fetch workspace Cycles
|
|
useSWR(
|
|
workspaceSlug ? `WORKSPACE_CYCLES_${workspaceSlug}` : null,
|
|
workspaceSlug ? () => fetchWorkspaceCycles(workspaceSlug.toString()) : null,
|
|
{ revalidateIfStale: false, revalidateOnFocus: false }
|
|
);
|
|
|
|
// fetch workspace labels
|
|
useSWR(
|
|
workspaceSlug ? `WORKSPACE_LABELS_${workspaceSlug}` : null,
|
|
workspaceSlug ? () => fetchWorkspaceLabels(workspaceSlug.toString()) : null,
|
|
{ revalidateIfStale: false, revalidateOnFocus: false }
|
|
);
|
|
|
|
// fetch workspace states
|
|
useSWR(
|
|
workspaceSlug ? `WORKSPACE_STATES_${workspaceSlug}` : null,
|
|
workspaceSlug ? () => fetchWorkspaceStates(workspaceSlug.toString()) : null,
|
|
{ revalidateIfStale: false, revalidateOnFocus: false }
|
|
);
|
|
|
|
// fetch workspace estimates
|
|
useSWR(
|
|
workspaceSlug ? `WORKSPACE_ESTIMATES_${workspaceSlug}` : null,
|
|
workspaceSlug ? () => fetchWorkspaceEstimates(workspaceSlug.toString()) : null,
|
|
{ revalidateIfStale: false, revalidateOnFocus: false }
|
|
);
|
|
};
|