Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export default function Page({

const { data: entity } = useSuspenseQuery({
queryKey: [modelId],
queryFn: () => getCircuit({ id: modelId, context: { virtualLabId, projectId } }),
queryFn: () =>
modelId ? getCircuit({ id: modelId, context: { virtualLabId, projectId } }) : null,
});

const {
Expand All @@ -52,7 +53,7 @@ export default function Page({
},
});

if (error) {
if (error || !entity) {
return notFound();
}

Expand Down
2 changes: 1 addition & 1 deletion src/entity-configuration/definitions/renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export function RenderCustomField<R extends EntityCoreIdentifiable>({
useEffect(() => {
async function getEntity() {
setPayload({ entity: null, error: null, loading: true });
if (entityConfig && entityConfig.api.query.one) {
if (entityConfig && entityConfig.api.query.one && entityId) {
const { data, error } = await tryCatch<R, any>(
// @ts-ignore
entityConfig.api.query.one({ id: entityId, context: { virtualLabId, projectId } })
Expand Down
5 changes: 3 additions & 2 deletions src/features/small-microcircuit/_components/atoms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ export const simulationsByCampaignIdAtomFamily = readAtomFamilyWithExpiration(

export const circuitAtomFamily = readAtomFamilyWithExpiration(
({ circuitId, context }: { circuitId: string; context: WorkspaceContext }) =>
atom<Promise<ICircuit>>(async () => {
return getCircuit({ id: circuitId, context });
atom<Promise<ICircuit | null>>(async () => {
if (circuitId) return getCircuit({ id: circuitId, context });
return null;
}),
{
ttl: 120000, // 2 minutes
Expand Down