Przeglądaj źródła

20230224: Done - dashboard v1

mkbeefcake 1 rok temu
rodzic
commit
216f62ad8d
2 zmienionych plików z 21 dodań i 20 usunięć
  1. 15 15
      src/App.tsx
  2. 6 5
      src/components/Dashboard/index.tsx

+ 15 - 15
src/App.tsx

@@ -294,21 +294,21 @@ class App extends React.Component<IProps, IState> {
 
         // console.log(`api.rpc.chain.subscribeNewHeads: ${id}`)
 
-        const isEven = id / 50 === Math.floor(id / 50);
-        if (isEven || status.block?.id + 50 < id) { 
-          this.updateStatus(api, id);
-        }
-
-        if (blocks.find((b) => b.id === id)) return;
-        const timestamp = (await api.query.timestamp.now()).toNumber();
-        const duration = status.block
-          ? timestamp - status.block.timestamp
-          : 6000;
-        status.block = { id, timestamp, duration };
-        this.save("status", status);
-
-        blocks = blocks.filter((i) => i.id !== id).concat(status.block);
-        this.setState({ blocks });
+        // const isEven = id / 50 === Math.floor(id / 50);
+        // if (isEven || status.block?.id + 50 < id) { 
+        //   this.updateStatus(api, id);
+        // }
+
+        // if (blocks.find((b) => b.id === id)) return;
+        // const timestamp = (await api.query.timestamp.now()).toNumber();
+        // const duration = status.block
+        //   ? timestamp - status.block.timestamp
+        //   : 6000;
+        // status.block = { id, timestamp, duration };
+        // this.save("status", status);
+
+        // blocks = blocks.filter((i) => i.id !== id).concat(status.block);
+        // this.setState({ blocks });
       });
     });
   }

+ 6 - 5
src/components/Dashboard/index.tsx

@@ -15,13 +15,14 @@ import { ElectedCouncil } from "@/types";
 import Proposals from "./Proposals";
 
 
-interface IProps extends IState {
-  council: ElectedCouncil
-}
+interface IProps extends IState {}
 const Dashboard = (props: IProps) => {
-  const { council } = props;
+  const { } = props;
+  const { data } = useElectedCouncils({});
 	const [description1, setDescription1] = useState('');
 
+	const council: ElectedCouncil | undefined = data && data[0]
+
 	useEffect(() => {
 		if (!council) 
       return
@@ -31,7 +32,7 @@ const Dashboard = (props: IProps) => {
 			", From: " + new Date(council.electedAt.timestamp) + 
 			", Councilors: [ " + council.councilors.map(each => each.member.handle).join(", ") + " ]")
 
-	}, [])
+	}, [council])
  
 
   return (