|
@ -1,13 +1,13 @@ |
|
|
import React, { Children } from 'react'; |
|
|
import React, { Children } from 'react'; |
|
|
import { breezeConstants } from '@ezerous/breeze'; |
|
|
import { breezeConstants } from '@ezerous/breeze'; |
|
|
import { useSelector } from 'react-redux'; |
|
|
import { useSelector } from 'react-redux'; |
|
|
import LoadingComponent from './LoadingComponent'; |
|
|
import CustomLoader from './CustomLoader'; |
|
|
|
|
|
|
|
|
// CSS |
|
|
// CSS |
|
|
import '../assets/css/loading-component.css'; |
|
|
import '../../assets/css/loading-component.css'; |
|
|
import { FORUM_CONTRACT } from '../constants/ContractNames'; |
|
|
import { FORUM_CONTRACT } from '../../constants/ContractNames'; |
|
|
|
|
|
|
|
|
const LoadingContainer = ({ children }) => { |
|
|
const InitializationLoader = ({ children }) => { |
|
|
const initializing = useSelector((state) => state.drizzleStatus.initializing); |
|
|
const initializing = useSelector((state) => state.drizzleStatus.initializing); |
|
|
const failed = useSelector((state) => state.drizzleStatus.failed); |
|
|
const failed = useSelector((state) => state.drizzleStatus.failed); |
|
|
const ipfsStatus = useSelector((state) => state.ipfs.status); |
|
|
const ipfsStatus = useSelector((state) => state.ipfs.status); |
|
@ -22,7 +22,7 @@ const LoadingContainer = ({ children }) => { |
|
|
|
|
|
|
|
|
if (!window.ethereum) { |
|
|
if (!window.ethereum) { |
|
|
return ( |
|
|
return ( |
|
|
<LoadingComponent |
|
|
<CustomLoader |
|
|
title="Couldn't detect MetaMask!" |
|
|
title="Couldn't detect MetaMask!" |
|
|
message={['Please make sure to install ', <a href="https://metamask.io/">MetaMask</a>, ' first.']} |
|
|
message={['Please make sure to install ', <a href="https://metamask.io/">MetaMask</a>, ' first.']} |
|
|
imageType="ethereum" |
|
|
imageType="ethereum" |
|
@ -34,7 +34,7 @@ const LoadingContainer = ({ children }) => { |
|
|
|
|
|
|
|
|
if ((web3Status === 'initializing' || !web3NetworkId) && !web3NetworkFailed) { |
|
|
if ((web3Status === 'initializing' || !web3NetworkId) && !web3NetworkFailed) { |
|
|
return ( |
|
|
return ( |
|
|
<LoadingComponent |
|
|
<CustomLoader |
|
|
title="Connecting to the Ethereum network..." |
|
|
title="Connecting to the Ethereum network..." |
|
|
message="Please make sure to unlock MetaMask and grant the app the right to connect to your account." |
|
|
message="Please make sure to unlock MetaMask and grant the app the right to connect to your account." |
|
|
imageType="ethereum" |
|
|
imageType="ethereum" |
|
@ -46,7 +46,7 @@ const LoadingContainer = ({ children }) => { |
|
|
|
|
|
|
|
|
if (web3Status === 'failed' || web3NetworkFailed) { |
|
|
if (web3Status === 'failed' || web3NetworkFailed) { |
|
|
return ( |
|
|
return ( |
|
|
<LoadingComponent |
|
|
<CustomLoader |
|
|
title="No connection to the Ethereum network!" |
|
|
title="No connection to the Ethereum network!" |
|
|
message="Please make sure that:" |
|
|
message="Please make sure that:" |
|
|
messageList={['MetaMask is unlocked and pointed to the correct, available network', |
|
|
messageList={['MetaMask is unlocked and pointed to the correct, available network', |
|
@ -60,7 +60,7 @@ const LoadingContainer = ({ children }) => { |
|
|
|
|
|
|
|
|
if (web3Status === 'initialized' && web3AccountsFailed) { |
|
|
if (web3Status === 'initialized' && web3AccountsFailed) { |
|
|
return ( |
|
|
return ( |
|
|
<LoadingComponent |
|
|
<CustomLoader |
|
|
title="We can't find any Ethereum accounts!" |
|
|
title="We can't find any Ethereum accounts!" |
|
|
message="Please make sure that MetaMask is unlocked." |
|
|
message="Please make sure that MetaMask is unlocked." |
|
|
imageType="ethereum" |
|
|
imageType="ethereum" |
|
@ -72,7 +72,7 @@ const LoadingContainer = ({ children }) => { |
|
|
|
|
|
|
|
|
if (initializing || (!failed && !contractInitialized && contractDeployed)) { |
|
|
if (initializing || (!failed && !contractInitialized && contractDeployed)) { |
|
|
return ( |
|
|
return ( |
|
|
<LoadingComponent |
|
|
<CustomLoader |
|
|
title="Initializing contracts..." |
|
|
title="Initializing contracts..." |
|
|
message="" |
|
|
message="" |
|
|
imageType="ethereum" |
|
|
imageType="ethereum" |
|
@ -84,7 +84,7 @@ const LoadingContainer = ({ children }) => { |
|
|
|
|
|
|
|
|
if (!contractDeployed) { |
|
|
if (!contractDeployed) { |
|
|
return ( |
|
|
return ( |
|
|
<LoadingComponent |
|
|
<CustomLoader |
|
|
title="No contracts found on the current network!" |
|
|
title="No contracts found on the current network!" |
|
|
message="Please make sure that you are connected to the correct network and the contracts are deployed." |
|
|
message="Please make sure that you are connected to the correct network and the contracts are deployed." |
|
|
imageType="ethereum" |
|
|
imageType="ethereum" |
|
@ -96,7 +96,7 @@ const LoadingContainer = ({ children }) => { |
|
|
|
|
|
|
|
|
if (ipfsStatus === breezeConstants.STATUS_INITIALIZING) { |
|
|
if (ipfsStatus === breezeConstants.STATUS_INITIALIZING) { |
|
|
return ( |
|
|
return ( |
|
|
<LoadingComponent |
|
|
<CustomLoader |
|
|
title="Initializing IPFS..." |
|
|
title="Initializing IPFS..." |
|
|
message="" |
|
|
message="" |
|
|
imageType="ipfs" |
|
|
imageType="ipfs" |
|
@ -108,7 +108,7 @@ const LoadingContainer = ({ children }) => { |
|
|
|
|
|
|
|
|
if (ipfsStatus === breezeConstants.STATUS_FAILED) { |
|
|
if (ipfsStatus === breezeConstants.STATUS_FAILED) { |
|
|
return ( |
|
|
return ( |
|
|
<LoadingComponent |
|
|
<CustomLoader |
|
|
title="IPFS initialization failed!" |
|
|
title="IPFS initialization failed!" |
|
|
message="" |
|
|
message="" |
|
|
imageType="ipfs" |
|
|
imageType="ipfs" |
|
@ -123,7 +123,7 @@ const LoadingContainer = ({ children }) => { |
|
|
? 'If needed, please sign the transaction in MetaMask to create the databases.' |
|
|
? 'If needed, please sign the transaction in MetaMask to create the databases.' |
|
|
: 'Please sign the transaction in MetaMask to create the databases.'; |
|
|
: 'Please sign the transaction in MetaMask to create the databases.'; |
|
|
return ( |
|
|
return ( |
|
|
<LoadingComponent |
|
|
<CustomLoader |
|
|
title="Preparing OrbitDB..." |
|
|
title="Preparing OrbitDB..." |
|
|
message={message} |
|
|
message={message} |
|
|
imageType="orbit" |
|
|
imageType="orbit" |
|
@ -135,7 +135,7 @@ const LoadingContainer = ({ children }) => { |
|
|
|
|
|
|
|
|
if (orbitStatus === breezeConstants.STATUS_FAILED) { |
|
|
if (orbitStatus === breezeConstants.STATUS_FAILED) { |
|
|
return ( |
|
|
return ( |
|
|
<LoadingComponent |
|
|
<CustomLoader |
|
|
title="OrbitDB initialization failed!" |
|
|
title="OrbitDB initialization failed!" |
|
|
message="" |
|
|
message="" |
|
|
imageType="orbit" |
|
|
imageType="orbit" |
|
@ -147,7 +147,7 @@ const LoadingContainer = ({ children }) => { |
|
|
|
|
|
|
|
|
if (!userFetched) { |
|
|
if (!userFetched) { |
|
|
return ( |
|
|
return ( |
|
|
<LoadingComponent |
|
|
<CustomLoader |
|
|
title="Loading dapp..." |
|
|
title="Loading dapp..." |
|
|
message="" |
|
|
message="" |
|
|
imageType="app" |
|
|
imageType="app" |
|
@ -160,4 +160,4 @@ const LoadingContainer = ({ children }) => { |
|
|
return Children.only(children); |
|
|
return Children.only(children); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
export default LoadingContainer; |
|
|
export default InitializationLoader; |