Skip to content

Commit c466bd0

Browse files
committed
fix: update more dependency array bugs
1 parent cb16dba commit c466bd0

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

site/src/modules/templates/useWatchVersionLogs.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,11 @@ export const useWatchVersionLogs = (
1515
setLogs(undefined);
1616
}
1717

18-
const templateVersionStatus = templateVersion?.job.status;
1918
const stableOnDone = useEffectEvent(() => options?.onDone());
19+
const status = templateVersion?.job.status;
20+
const canWatch = status === "running" || status === "pending";
2021
useEffect(() => {
21-
if (!templateVersionId || !templateVersionStatus) {
22-
return;
23-
}
24-
25-
if (
26-
templateVersionStatus !== "running" &&
27-
templateVersionStatus !== "pending"
28-
) {
22+
if (!templateVersionId || !canWatch) {
2923
return;
3024
}
3125

@@ -40,7 +34,7 @@ export const useWatchVersionLogs = (
4034
});
4135

4236
return () => socket.close();
43-
}, [stableOnDone, templateVersionId, templateVersionStatus]);
37+
}, [stableOnDone, canWatch, templateVersionId]);
4438

4539
return logs;
4640
};

0 commit comments

Comments
 (0)