Skip to content

Commit a18c71a

Browse files
committed
fix
1 parent 47a422f commit a18c71a

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

components/Settings/NodeInfoDialog.tsx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,30 @@ export const NodeInfoDialog: FC<Props> = ({ open, onClose }) => {
1717
const [nodeInfo, setNodeInfo] = useState<any>();
1818
const [loading, setLoading] = useState<boolean>(true);
1919

20+
const {
21+
state: { selectedNode },
22+
dispatch,
23+
} = useContext(HomeContext);
24+
2025
useEffect(() => {
21-
if (!open) return;
22-
setLoading(true);
26+
if (!selectedNode?.subdomain) return;
2327
fetch(`/config_pub.json`)
24-
.then((response) => response.json())
25-
.then((data) => {
26-
setNodeInfo(data);
27-
setLoading(false);
28-
})
29-
.catch((error) => {
30-
setLoading(false);
31-
console.error('Error fetching JSON:', error);
32-
});
33-
}, [open]);
28+
.then((response) => response.json())
29+
.then((data) => {
30+
setNodeInfo(data);
31+
if (data?.system_prompt) {
32+
dispatch({
33+
field: 'selectedNodeSystemPrompt',
34+
value: data?.system_prompt,
35+
});
36+
}
37+
setLoading(false);
38+
})
39+
.catch((error) => {
40+
console.error('Error fetching JSON:', error);
41+
setLoading(false);
42+
});
43+
}, [dispatch, selectedNode]);
3444

3545
useEffect(() => {
3646
const handleMouseDown = (e: MouseEvent) => {

0 commit comments

Comments
 (0)