Skip to content

Commit 0f28775

Browse files
committed
fix(domains): don't fetch AddDomain queries until the dialog opens
Fixes Dokploy#5279. The Domains table (and grid) view mounts one AddDomain instance per row for the edit action. Its 4 queries (domain.one, application.one/compose.one, domain.canGenerateTraefikMeDomains, compose.loadServices) ran unconditionally on mount instead of only when the edit dialog is open, so any table interaction that causes a re-render (typing in the host filter, sorting, toggling columns) fired all 4 queries for every domain row again.
1 parent 150c34d commit 0f28775

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

‎apps/dokploy/components/dashboard/application/domains/handle-domain.tsx‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export const AddDomain = ({ id, type, domainId = "", children }: Props) => {
156156
domainId,
157157
},
158158
{
159-
enabled: !!domainId,
159+
enabled: isOpen && !!domainId,
160160
},
161161
);
162162

@@ -167,15 +167,15 @@ export const AddDomain = ({ id, type, domainId = "", children }: Props) => {
167167
applicationId: id,
168168
},
169169
{
170-
enabled: !!id,
170+
enabled: isOpen && !!id,
171171
},
172172
)
173173
: api.compose.one.useQuery(
174174
{
175175
composeId: id,
176176
},
177177
{
178-
enabled: !!id,
178+
enabled: isOpen && !!id,
179179
},
180180
);
181181

@@ -187,9 +187,14 @@ export const AddDomain = ({ id, type, domainId = "", children }: Props) => {
187187
api.domain.generateDomain.useMutation();
188188

189189
const { data: canGenerateTraefikMeDomains } =
190-
api.domain.canGenerateTraefikMeDomains.useQuery({
191-
serverId: application?.serverId || "",
192-
});
190+
api.domain.canGenerateTraefikMeDomains.useQuery(
191+
{
192+
serverId: application?.serverId || "",
193+
},
194+
{
195+
enabled: isOpen,
196+
},
197+
);
193198

194199
const {
195200
data: services,
@@ -204,7 +209,7 @@ export const AddDomain = ({ id, type, domainId = "", children }: Props) => {
204209
{
205210
retry: false,
206211
refetchOnWindowFocus: false,
207-
enabled: type === "compose" && !!id,
212+
enabled: isOpen && type === "compose" && !!id,
208213
},
209214
);
210215

0 commit comments

Comments
 (0)