Feature/nym connect gateway performance (#2824)

* set up ui for gateway performance in nym-connect

remove duplicated imports

* set and reset (when necessary) gateway performance

* remove unneeded useEffect

* remove log
This commit is contained in:
Fouad
2023-01-12 09:47:58 +00:00
committed by GitHub
parent c7d8f3af97
commit 5f88517e1d
+10 -16
View File
@@ -57,6 +57,8 @@ export const ClientContextProvider = ({ children }: { children: React.ReactNode
setAppVersion(version);
};
const timerId = useRef<NodeJS.Timeout>();
useEffect(() => {
invoke('get_services').then((result) => {
setServices(result as Services);
@@ -97,8 +99,14 @@ export const ClientContextProvider = ({ children }: { children: React.ReactNode
listen('socks5-status-event', (e: TauriEvent) => {
if (e.payload.message.includes('slow')) {
setGatewayPerformance('Poor');
} else {
setGatewayPerformance('Good');
if (timerId.current) {
clearTimeout(timerId.current);
}
timerId.current = setTimeout(() => {
setGatewayPerformance('Good');
}, 10000);
}
}).then((result) => {
unlisten.push(result);
@@ -179,20 +187,6 @@ export const ClientContextProvider = ({ children }: { children: React.ReactNode
getSpFromStorage();
}, []);
const timerId = useRef<NodeJS.Timeout>();
useEffect(() => {
if (timerId.current) {
clearTimeout(timerId.current);
}
if (gatewayPerformance !== 'Good') {
timerId.current = setTimeout(() => {
setGatewayPerformance('Good');
}, 15000);
}
}, [gatewayPerformance]);
const contextValue = useMemo(
() => ({
mode,