Skip to content

Commit

Permalink
chore(meshupgrade): fix refetchLosses is not a function
Browse files Browse the repository at this point in the history
  • Loading branch information
selankon committed Mar 25, 2024
1 parent d71eb5c commit 851e104
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions plugins/lime-plugin-rx/src/sections/internetPath.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Trans } from "@lingui/macro";
import { useCallback } from "react";

import { Button } from "components/elements/button";
import { GlobeIcon } from "components/icons/globeIcon";
Expand All @@ -20,27 +21,6 @@ import { IGetInternetStatus } from "plugins/lime-plugin-rx/src/rxApi";
import { useInternetStatus } from "plugins/lime-plugin-rx/src/rxQueries";

export const InternetPath = () => {
const { data: internet, isLoading: internetStatusLoading } =
useInternetStatus({
structuralSharing: (
oldData: IGetInternetStatus,
newData: IGetInternetStatus
) => {
if (
// If is the first execution and there are no internet
(!oldData &&
!(newData.IPv4.working || newData.IPv6.working)) ||
// If the old data and new data are different
(oldData &&
(oldData.IPv4.working || oldData.IPv6.working) !==
(newData.IPv4.working || newData.IPv6.working))
) {
refetchLosses();
}
return newData;
},
});

const {
data: path,
isLoading: pathIsLoading,
Expand All @@ -50,10 +30,6 @@ export const InternetPath = () => {
enabled: true,
});

const workingInternet =
!internetStatusLoading &&
(internet.IPv4.working || internet.IPv6.working);

const pathLoss =
path
?.map((station) => {
Expand All @@ -68,9 +44,34 @@ export const InternetPath = () => {
initialData: [],
});

const checkLosses = async () => {
const { data: internet, isLoading: internetStatusLoading } =
useInternetStatus({
structuralSharing: (
oldData: IGetInternetStatus,
newData: IGetInternetStatus
) => {
if (
// If is the first execution and there are no internet
(!oldData &&
!(newData.IPv4.working || newData.IPv6.working)) ||
// If the old data and new data are different
(oldData &&
(oldData.IPv4.working || oldData.IPv6.working) !==
(newData.IPv4.working || newData.IPv6.working))
) {
if (refetchLosses) refetchLosses();
}
return newData;
},
});

const checkLosses = useCallback(async () => {
refetchLosses();
};
}, [refetchLosses]);

const workingInternet =
!internetStatusLoading &&
(internet.IPv4.working || internet.IPv6.working);

// Conditional rendering for las known path
let pathComponent = (
Expand Down

0 comments on commit 851e104

Please sign in to comment.