|
@@ -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...");
|