Skip to content

Commit

Permalink
chore(meshwide): sync node on component mount
Browse files Browse the repository at this point in the history
  • Loading branch information
selankon committed May 10, 2024
1 parent 4f63c93 commit 769cbbd
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Trans } from "@lingui/macro";
import { useState } from "preact/hooks";
import { useEffect, useState } from "preact/hooks";
import { useCallback } from "react";

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

const [isLoading, setIsLoading] = useState(false);
const { showToast } = useToast();
const { showToast, hideToast } = useToast();

const { mutateAsync: localNodeSync } = useSyncDataTypes({
ip,
Expand Down Expand Up @@ -76,6 +76,14 @@ const UpdateNodeInfoBtn = ({ node }: { node: INodeInfo }) => {
showToast,
]);

// Use effect to sync the node data on mount
useEffect(() => {
(async () => {
await syncNode();
})();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [node.ipv4]);

return (
<Button
color={"primary"}
Expand Down

0 comments on commit 769cbbd

Please sign in to comment.