mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-26 23:30:09 +08:00
chore(deps): lock file maintenance npm dependencies (#6015)
* chore(deps): lock file maintenance npm dependencies * chore(deps): bump npm deps * chore: fix eslint ref-name --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Slinetrac <realakayuki@gmail.com>
This commit is contained in:
co-authored by
renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Slinetrac
parent
256a3f697b
commit
2128e1f788
@@ -3,12 +3,12 @@ import { listen, UnlistenFn, EventCallback } from "@tauri-apps/api/event";
|
||||
import { useCallback, useRef } from "react";
|
||||
|
||||
export const useListen = () => {
|
||||
const unlistenFns = useRef<UnlistenFn[]>([]);
|
||||
const unlistenFnsRef = useRef<UnlistenFn[]>([]);
|
||||
|
||||
const addListener = useCallback(
|
||||
async <T>(eventName: string, handler: EventCallback<T>) => {
|
||||
const unlisten = await listen(eventName, handler);
|
||||
unlistenFns.current.push(unlisten);
|
||||
unlistenFnsRef.current.push(unlisten);
|
||||
return unlisten;
|
||||
},
|
||||
[],
|
||||
@@ -17,7 +17,7 @@ export const useListen = () => {
|
||||
const removeAllListeners = useCallback(() => {
|
||||
const errors: Error[] = [];
|
||||
|
||||
unlistenFns.current.forEach((unlisten) => {
|
||||
unlistenFnsRef.current.forEach((unlisten) => {
|
||||
try {
|
||||
unlisten();
|
||||
} catch (error) {
|
||||
@@ -32,7 +32,7 @@ export const useListen = () => {
|
||||
);
|
||||
}
|
||||
|
||||
unlistenFns.current.length = 0;
|
||||
unlistenFnsRef.current.length = 0;
|
||||
}, []);
|
||||
|
||||
const setupCloseListener = useCallback(async () => {
|
||||
|
||||
@@ -109,19 +109,19 @@ export const useLogData = () => {
|
||||
},
|
||||
});
|
||||
|
||||
const previousLogLevel = useRef<string | undefined>(undefined);
|
||||
const previousLogLevelRef = useRef<string | undefined>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
if (!logLevel) {
|
||||
previousLogLevel.current = logLevel ?? undefined;
|
||||
previousLogLevelRef.current = logLevel ?? undefined;
|
||||
return;
|
||||
}
|
||||
|
||||
if (previousLogLevel.current === logLevel) {
|
||||
if (previousLogLevelRef.current === logLevel) {
|
||||
return;
|
||||
}
|
||||
|
||||
previousLogLevel.current = logLevel;
|
||||
previousLogLevelRef.current = logLevel;
|
||||
refresh();
|
||||
}, [logLevel, refresh]);
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ export const useMihomoWsSubscription = <T>(
|
||||
const subscriptionCacheKey = subscriptKey ? `$sub$${subscriptKey}` : null;
|
||||
|
||||
const wsRef = useRef<MihomoWebSocket | null>(null);
|
||||
const wsFirstConnection = useRef<boolean>(true);
|
||||
const wsFirstConnectionRef = useRef<boolean>(true);
|
||||
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
const response = useSWRSubscription<T, any, string | null>(
|
||||
@@ -124,15 +124,15 @@ export const useMihomoWsSubscription = <T>(
|
||||
}
|
||||
}
|
||||
|
||||
if (wsFirstConnection.current || !wsRef.current) {
|
||||
wsFirstConnection.current = false;
|
||||
if (wsFirstConnectionRef.current || !wsRef.current) {
|
||||
wsFirstConnectionRef.current = false;
|
||||
cleanupAll();
|
||||
void connectWs();
|
||||
}
|
||||
|
||||
return () => {
|
||||
isMounted = false;
|
||||
wsFirstConnection.current = true;
|
||||
wsFirstConnectionRef.current = true;
|
||||
cleanupAll();
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user