fix initial loading

This commit is contained in:
Andrea Franz 2019-12-04 16:59:14 +01:00
parent 5d52326725
commit 4a1b836f23
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
3 changed files with 24 additions and 10 deletions

View File

@ -12,7 +12,6 @@ import CssBaseline from '@material-ui/core/CssBaseline';
import Avatar from '@material-ui/core/Avatar'; import Avatar from '@material-ui/core/Avatar';
import CircularProgress from '@material-ui/core/CircularProgress'; import CircularProgress from '@material-ui/core/CircularProgress';
import { newWalletSelectIcon } from "../actions"
import { compressedAddress } from '../utils'; import { compressedAddress } from '../utils';
import { Props } from '../containers/App'; import { Props } from '../containers/App';
@ -54,7 +53,7 @@ const App = (props: Props) => {
let body = loading; let body = loading;
//FIXME: check if loading //FIXME: check if loading
if (props.web3Initialized) { if (!props.loading) {
body = <> body = <>
<TopPanel /> <TopPanel />
<TransactionsList /> <TransactionsList />

View File

@ -4,7 +4,7 @@ import { RootState } from '../reducers';
import { Dispatch } from 'redux'; import { Dispatch } from 'redux';
export interface StateProps { export interface StateProps {
web3Initialized: boolean loading: boolean
web3Error: string | undefined web3Error: string | undefined
walletAddress: string | undefined walletAddress: string | undefined
networkID: number | undefined networkID: number | undefined
@ -16,13 +16,17 @@ export interface DispatchProps {
export type Props = StateProps & DispatchProps; export type Props = StateProps & DispatchProps;
const mapStateToProps = (state: RootState): StateProps => ({ const mapStateToProps = (state: RootState): StateProps => {
web3Initialized: state.web3.initialized, const ready = state.web3.initialized && state.wallet.ready;
web3Error: state.web3.error,
networkID: state.web3.networkID, return {
walletAddress: state.wallet.walletAddress, loading: !ready,
walletError: state.wallet.error, web3Error: state.web3.error,
}); networkID: state.web3.networkID,
walletAddress: state.wallet.walletAddress,
walletError: state.wallet.error,
}
};
const mapDispatchToProps = (dispatch: Dispatch): DispatchProps => ({ const mapDispatchToProps = (dispatch: Dispatch): DispatchProps => ({
}); });

View File

@ -10,6 +10,7 @@ import {
} from '../actions/wallet'; } from '../actions/wallet';
export interface WalletState { export interface WalletState {
ready: boolean
loading: boolean loading: boolean
keycardAddress: string | undefined keycardAddress: string | undefined
walletAddress: string | undefined walletAddress: string | undefined
@ -20,6 +21,7 @@ export interface WalletState {
} }
const initialState = { const initialState = {
ready: false,
loading: false, loading: false,
keycardAddress: undefined, keycardAddress: undefined,
walletAddress: undefined, walletAddress: undefined,
@ -56,14 +58,23 @@ export const walletReducer = (state: WalletState = initialState, action: WalletA
case WALLET_FACTORY_WALLET_ADDRESS_LOADED: { case WALLET_FACTORY_WALLET_ADDRESS_LOADED: {
return { return {
...state, ...state,
loading: false,
walletFound: true, walletFound: true,
walletAddress: action.walletAddress, walletAddress: action.walletAddress,
} }
} }
case WALLET_LOADING_BALANCE: {
return {
...state,
loading: true,
}
}
case WALLET_BALANCE_LOADED: { case WALLET_BALANCE_LOADED: {
return { return {
...state, ...state,
ready: true,
loading: false, loading: false,
balance: action.balance, balance: action.balance,
} }