Browse Source

remove redundant

Joystream Stats 4 years ago
parent
commit
ae3049af01

+ 2 - 47
src/App.tsx

@@ -2,16 +2,14 @@ import React from "react";
 import "bootstrap/dist/css/bootstrap.min.css";
 import "./index.css";
 import { Routes, Loading } from "./components";
-import moment from "moment";
 import * as get from "./lib/getters";
 import { domain, wsLocation } from "./config";
 
 // types
-import { Api, Block, NominatorsEntries, Proposals } from "./types";
+import { Api, Block } from "./types";
 import { types } from "@joystream/types";
 import { ApiPromise, WsProvider } from "@polkadot/api";
 import { Header } from "@polkadot/types/interfaces";
-import { ValidatorId } from "@polkadot/types/interfaces";
 
 interface IProps {}
 
@@ -54,19 +52,10 @@ class App extends React.Component<IProps, IState> {
     const provider = new WsProvider(wsLocation);
     const api = await ApiPromise.create({ provider, types });
     await api.isReady;
-    //this.setState({loading:false})
-
-    // const [chain, node, version] = await Promise.all([
-    //   api.rpc.system.chain(),
-    //   api.rpc.system.name(),
-    //   api.rpc.system.version()
-    // ]);
-    // this.setState({ chain, node, version, loading: false });
+    this.setState({ loading: false });
 
     let blocks: Block[] = [];
     let lastBlock: Block = { id: 0, timestamp: 0, duration: 6 };
-    let openingId = await get.nextOpeningId(api);
-    let nextWorkerId = await get.nextWorkerId(api);
 
     let channels = [];
     channels[0] = await get.currentChannelId(api);
@@ -84,10 +73,6 @@ class App extends React.Component<IProps, IState> {
       this.fetchProposal(api, i);
     }
 
-    //proposals.last = await get.proposalCount(api);
-    //proposals.active = await get.activeProposalCount(api);
-    //proposals.executing = await get.pendingProposals(api);
-
     this.setState({ channels, proposalCount, posts, categories, threads });
 
     const council: any = await api.query.council.activeCouncil();
@@ -128,29 +113,6 @@ class App extends React.Component<IProps, IState> {
         posts[1] = await get.currentPostId(api);
         threads[1] = await get.currentThreadId(api);
         lastBlock = block;
-
-        // test storage providers
-        // if (block.timestamp > lastCheck + checkPeriod) {
-        //   lastCheck = block.timestamp;
-        // }
-        // new storage provider (or lead) opportunity is opened
-        // const nextOpeningId = await get.nextOpeningId(api);
-        // if (nextOpeningId > openingId) {
-        //   openingId = nextOpeningId;
-        // }
-
-        // storage provider (or lead) opportunity is closed
-        // const workerId = await get.nextWorkerId(api);
-        // if (workerId > nextWorkerId) {
-        //   const worker = await api.query.storageWorkingGroup.workerById(
-        //     workerId - 1
-        //   );
-        //   const memberId = worker.member_id.toJSON();
-        //   const handle: string = await get.memberHandle(api, memberId);
-        //   nextWorkerId = workerId;
-        // }
-
-        lastBlock = block;
       }
     );
   }
@@ -163,17 +125,11 @@ class App extends React.Component<IProps, IState> {
   }
   async fetchHandle(api: Api, id: string) {
     const handle = await get.memberHandleByAccount(api, id);
-    //if (handle === "") return;
     let { handles } = this.state;
     handles[String(id)] = handle;
     this.setState({ handles });
   }
 
-  // async fetchData() {
-  //   // inital axios requests go here
-  //   this.setState({ loading: false });
-  // }
-
   render() {
     if (this.state.loading) return <Loading />;
     return <Routes {...this.state} />;
@@ -181,7 +137,6 @@ class App extends React.Component<IProps, IState> {
 
   componentDidMount() {
     this.initializeSocket();
-    //this.fetchData()
   }
   componentWillUnmount() {
     console.log("unmounting...");

+ 7 - 2
src/components/Proposals/ProposalOverlay.tsx

@@ -12,6 +12,7 @@ const ProposalOverlay = (props: any) => {
 
   return (
     <OverlayTrigger
+      key={createdAt}
       placement="right"
       delay={{ show: 250, hide: 400 }}
       overlay={
@@ -19,9 +20,13 @@ const ProposalOverlay = (props: any) => {
           <div>
             Time to vote: {remainingBlocks} blocks ({days}d {hours}h)
           </div>
-          <div className="my-2 text-left">
-            {htmr(props.message.replace(/\n/, "<br/>"))}
+
+          <div className="my-2 p-1 bg-light  text-secondary text-left">
+            {props.message.split(/\n/).map((line: string) => (
+              <div>{htmr(line)}</div>
+            ))}
           </div>
+
           {props.description}
         </Tooltip>
       }

+ 1 - 1
src/components/Proposals/index.tsx

@@ -2,7 +2,7 @@ import React from "react";
 import Proposal from "./Proposal";
 
 const Proposals = (props: any) => {
-  const { count, proposals } = props;
+  const { proposals } = props;
 
   const active = proposals.filter((p: any) => p.stage === "Active");
   const executing = proposals.filter((p: any) => p.exec);

+ 1 - 1
src/components/User/index.tsx

@@ -1,6 +1,6 @@
 import React from "react";
 import { OverlayTrigger, Tooltip } from "react-bootstrap";
-import { domain } from "../../config";
+//import { domain } from "../../config";
 
 const shortName = (name: string) => {
   return `${name.slice(0, 5)}..${name.slice(+name.length - 5)}`;

+ 2 - 5
src/lib/announcements.ts

@@ -7,7 +7,7 @@ import {
   Summary,
 } from '../types'
 import { BlockNumber } from '@polkadot/types/interfaces'
-import { Channel, ElectionStage } from '@joystream/types/augment'
+import { Channel } from '@joystream/types/augment'
 import { Category, Thread, Post } from '@joystream/types/forum'
 import { formatTime } from './util'
 import {
@@ -79,13 +79,10 @@ export const council = async (
     msg = `<a href="${domain}/#/council/members">Council ${round}</a> elected at block ${block} until block ${councilEnd}. Next election: ${endDate} (${remainingBlocks} blocks)`
   } else {
     if (stageString === 'Announcing') {
-      const announcingPeriod: BlockNumber = await api.query.councilElection.announcingPeriod()
       msg = `Announcing election for round ${round} started.<a href="${domain}/#/council/applicants">Apply now!</a>`
     } else if (stageString === 'Voting') {
-      const votingPeriod: BlockNumber = await api.query.councilElection.votingPeriod()
       msg = `Voting stage for council election started. <a href="${domain}/#/council/applicants">Vote now!</a>`
     } else if (stageString === 'Revealing') {
-      const revealingPeriod: BlockNumber = await api.query.councilElection.revealingPeriod()
       msg = `Revealing stage for council election started. <a href="${domain}/#/council/votes">Don't forget to reveal your vote!</a>`
     } else console.log(`[council] unrecognized stage: ${stageString}`)
   }
@@ -182,7 +179,7 @@ export const proposals = async (
 
   for (let id: number = +last + 1; id <= current; id++) {
     const proposal: ProposalDetail = await proposalDetail(api, id)
-    const { createdAt, finalizedAt, message, parameters, result } = proposal
+    const { createdAt, message, parameters } = proposal
     const votingEndsAt = createdAt + parameters.votingPeriod.toNumber()
     const msg = `Proposal ${id} <b>created</b> at block ${createdAt}.\r\n${message}\r\nYou can vote until block ${votingEndsAt}.`
     sendMessage(msg)

+ 1 - 1
src/lib/util.ts

@@ -1,4 +1,4 @@
-import { Api, Options, Proposals } from "../types";
+import { Options, Proposals } from "../types";
 import moment from "moment";
 
 export const parseArgs = (args: string[]): Options => {