Skip to content

Commit 769cbbd

Browse files
committed
chore(meshwide): sync node on component mount
1 parent 4f63c93 commit 769cbbd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Diff for: plugins/lime-plugin-mesh-wide/src/components/FeatureDetail/UpdateNodeInfoBtn.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Trans } from "@lingui/macro";
2-
import { useState } from "preact/hooks";
2+
import { useEffect, useState } from "preact/hooks";
33
import { useCallback } from "react";
44

55
import { Button } from "components/buttons/button";
@@ -23,7 +23,7 @@ const UpdateNodeInfoBtn = ({ node }: { node: INodeInfo }) => {
2323
const ip = node.ipv4;
2424

2525
const [isLoading, setIsLoading] = useState(false);
26-
const { showToast } = useToast();
26+
const { showToast, hideToast } = useToast();
2727

2828
const { mutateAsync: localNodeSync } = useSyncDataTypes({
2929
ip,
@@ -76,6 +76,14 @@ const UpdateNodeInfoBtn = ({ node }: { node: INodeInfo }) => {
7676
showToast,
7777
]);
7878

79+
// Use effect to sync the node data on mount
80+
useEffect(() => {
81+
(async () => {
82+
await syncNode();
83+
})();
84+
// eslint-disable-next-line react-hooks/exhaustive-deps
85+
}, [node.ipv4]);
86+
7987
return (
8088
<Button
8189
color={"primary"}

0 commit comments

Comments
 (0)