Procházet zdrojové kódy

从记忆的用户设置中读取状态

visuddhinanda před 3 roky
rodič
revize
d63fb46cab
1 změnil soubory, kde provedl 21 přidání a 18 odebrání
  1. 21 18
      dashboard/src/components/template/SentRead.tsx

+ 21 - 18
dashboard/src/components/template/SentRead.tsx

@@ -32,26 +32,29 @@ const SentReadFrame = ({
   const boxSent = useRef<HTMLDivElement>(null);
 
   useEffect(() => {
-    switch (key) {
-      case "setting.display.original":
-        if (boxOrg.current) {
-          if (value === true) {
-            boxOrg.current.style.display = "block";
-          } else {
-            boxOrg.current.style.display = "none";
-          }
+    const displayOriginal = GetUserSetting(
+      "setting.display.original",
+      settings
+    );
+    if (typeof displayOriginal === "boolean") {
+      if (boxOrg.current) {
+        if (displayOriginal === true) {
+          boxOrg.current.style.display = "block";
+        } else {
+          boxOrg.current.style.display = "none";
         }
-        break;
-      case "setting.layout.direction":
-        if (boxSent.current) {
-          if (typeof value === "string") {
-            boxSent.current.style.flexDirection = value;
-          }
-        }
-        break;
-      default:
-        break;
+      }
     }
+    const layoutDirection = GetUserSetting(
+      "setting.layout.direction",
+      settings
+    );
+    if (typeof layoutDirection === "string") {
+      if (boxSent.current) {
+        boxSent.current.style.flexDirection = layoutDirection;
+      }
+    }
+
     const _paliCode1 = GetUserSetting("setting.pali.script.primary", settings);
     if (typeof _paliCode1 !== "undefined") {
       setPaliCode1(_paliCode1.toString() as TCodeConvertor);