Joystream Stats 3 years ago
parent
commit
71864244c7
3 changed files with 11 additions and 10 deletions
  1. 10 7
      src/App.tsx
  2. 1 1
      src/components/Proposals/Bar.tsx
  3. 0 2
      src/components/Storage/Asset.tsx

+ 10 - 7
src/App.tsx

@@ -223,10 +223,10 @@ class App extends React.Component<IProps, IState> {
     const { status } = this.state;
     if (era > status.era) {
       console.debug(`Updating validators`);
-      this.fetchLastReward(api, era - 1);
+      this.fetchLastReward(api, status.era);
       const validators = await this.fetchValidators(api);
       this.enqueue("stakes", () => this.fetchStakes(api, era, validators));
-    } else if (!status.lastReward) this.fetchLastReward(api, era - 1);
+    } else if (!status.lastReward) this.fetchLastReward(api);
     return era;
   }
 
@@ -277,9 +277,11 @@ class App extends React.Component<IProps, IState> {
     return array.filter((i) => i.id !== item.id).concat(item);
   }
 
-  async fetchLastReward(api: Api, era: number) {
-    const lastReward = Number(await api.query.staking.erasValidatorReward(era));
-    if (!lastReward) return this.fetchLastReward(api, era - 1);
+  async fetchLastReward(api: Api) {
+    const era: number = await this.updateEra(api);
+    const lastReward = Number(
+      await api.query.staking.erasValidatorReward(era - 2)
+    );
 
     console.debug(`reward era ${era}: ${lastReward} tJOY`);
     let { status } = this.state;
@@ -722,11 +724,12 @@ class App extends React.Component<IProps, IState> {
   async loadData() {
     const status = this.load("status");
     if (status)
-      if (status.version !== version) return this.clearData();
+      if (status.version !== version) return;
+      // this.clearData();
       else this.setState({ status });
     console.debug(`Loading data`);
     this.loadMembers();
-    "councils categories channels proposals posts threads handles mints tokenomics transactions reports validators nominators stakes stars"
+    "assets providers councils categories channels proposals posts threads handles mints tokenomics transactions reports validators nominators stakes stars"
       .split(" ")
       .map((key) => this.load(key));
   }

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

@@ -9,7 +9,7 @@ const Bar = (props: {
   expires: string;
   left: string;
 }) => {
-  const { blocks, created, expires, id, left, percent } = props;
+  const { created, expires, id, left, percent } = props;
   if (percent < 0) return <div>updating ..</div>;
   const bg = percent < 25 ? `danger` : percent < 50 ? `warning` : `success`;
 

+ 0 - 2
src/components/Storage/Asset.tsx

@@ -1,8 +1,6 @@
 import React, { useEffect } from "react";
 import moment from "moment";
 
-import { Link } from "react-router-dom";
-
 const Asset = (props: {
   loadAsset: (string, any, string) => void;
   provider: string;