Browse Source

fix: await compatibility in #8e78b9e

dongchengjie 11 tháng trước cách đây
mục cha
commit
66ae293ddd

+ 2 - 2
src/components/base/base-tooltip-icon.tsx

@@ -12,11 +12,11 @@ interface Props extends IconButtonProps {
 }
 
 export const TooltipIcon: React.FC<Props> = (props: Props) => {
-  const { title = "", icon: Icon = InfoRounded } = props;
+  const { title = "", icon: Icon = InfoRounded, ...restProps } = props;
 
   return (
     <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 }} />
       </IconButton>
     </Tooltip>

+ 7 - 3
src/components/layout/layout-traffic.tsx

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