元旦节皮肤
This commit is contained in:
@@ -58,6 +58,8 @@ export function DeviceProvider({ children }: { children: React.ReactNode }) {
|
||||
const [api, setApi] = useState<LuxsinAPI | null>(null);
|
||||
const lastMsgCountRef = useRef<number>(-1);
|
||||
const pollIntervalRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||
/** 轮询重入保护:上一轮未 settle(如断网挂起至超时)则跳过本轮,避免挂起请求堆叠。 */
|
||||
const pollInFlightRef = useRef(false);
|
||||
const autoConnectStartedRef = useRef(false);
|
||||
|
||||
const setDeviceIp = useCallback((newIp: string) => {
|
||||
@@ -260,6 +262,8 @@ export function DeviceProvider({ children }: { children: React.ReactNode }) {
|
||||
if (!isConnected || isDemoMode || !api) return;
|
||||
|
||||
const poll = async () => {
|
||||
if (pollInFlightRef.current) return;
|
||||
pollInFlightRef.current = true;
|
||||
try {
|
||||
const count = await api.getMsgCount();
|
||||
if (count !== lastMsgCountRef.current) {
|
||||
@@ -270,6 +274,8 @@ export function DeviceProvider({ children }: { children: React.ReactNode }) {
|
||||
}
|
||||
} catch {
|
||||
// Silently fail polling
|
||||
} finally {
|
||||
pollInFlightRef.current = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user