fix: await compatibility in #8e78b9e

This commit is contained in:
dongchengjie 2024-06-26 18:29:50 +08:00
parent 8e78b9e405
commit 66ae293ddd
2 changed files with 9 additions and 5 deletions

View File

@ -12,11 +12,11 @@ interface Props extends IconButtonProps {
} }
export const TooltipIcon: React.FC<Props> = (props: Props) => { export const TooltipIcon: React.FC<Props> = (props: Props) => {
const { title = "", icon: Icon = InfoRounded } = props; const { title = "", icon: Icon = InfoRounded, ...restProps } = props;
return ( return (
<Tooltip title={title} placement="top"> <Tooltip title={title} placement="top">
<IconButton color="inherit" size="small" {...props}> <IconButton color="inherit" size="small" {...restProps}>
<Icon fontSize="inherit" style={{ cursor: "pointer", opacity: 0.75 }} /> <Icon fontSize="inherit" style={{ cursor: "pointer", opacity: 0.75 }} />
</IconButton> </IconButton>
</Tooltip> </Tooltip>

View File

@ -1,4 +1,4 @@
import { useRef } from "react"; import { useEffect, useRef, useState } from "react";
import { Box, Typography } from "@mui/material"; import { Box, Typography } from "@mui/material";
import { import {
ArrowDownward, ArrowDownward,
@ -21,8 +21,6 @@ interface MemoryUsage {
oslimit?: number; oslimit?: number;
} }
const isDebug = await isDebugEnabled();
// setup the traffic // setup the traffic
export const LayoutTraffic = () => { export const LayoutTraffic = () => {
const { t } = useTranslation(); const { t } = useTranslation();
@ -34,6 +32,12 @@ export const LayoutTraffic = () => {
const trafficRef = useRef<TrafficRef>(null); const trafficRef = useRef<TrafficRef>(null);
const pageVisible = useVisibility(); const pageVisible = useVisibility();
const [isDebug, setIsDebug] = useState(false);
useEffect(() => {
isDebugEnabled().then((flag) => setIsDebug(flag));
return () => {};
}, [isDebug]);
// https://swr.vercel.app/docs/subscription#deduplication // https://swr.vercel.app/docs/subscription#deduplication
// useSWRSubscription auto deduplicates to one subscription per key per entire app // useSWRSubscription auto deduplicates to one subscription per key per entire app