Skip to content

Commit

Permalink
fix: fixed showing info when user not logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
Y0moo committed Dec 22, 2021
1 parent af6c3d3 commit 07bffdb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const App = ({ isServerInfo }) => {

useEffect(() => {
const connectorId = window.localStorage.getItem("connectorId");
console.log("connectorId", connectorId)
if (isAuthenticated && !isWeb3Enabled && !isWeb3EnableLoading) enableWeb3({ provider: connectorId });
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isAuthenticated, isWeb3Enabled]);
Expand Down
6 changes: 3 additions & 3 deletions src/components/Address/Address.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ const styles = {
};

function Address(props) {
const { account } = useMoralis();
const { account, isAuthenticated } = useMoralis();
const [address, setAddress] = useState();
const [isClicked, setIsClicked] = useState(false);

useEffect(() => {
setAddress(props?.address || account);
}, [account, props]);
setAddress(props?.address || (isAuthenticated && account));
}, [account, isAuthenticated, props]);

if (!address) return <Skeleton paragraph={{ rows: 1, width: "100%" }} title={false} active />;

Expand Down
10 changes: 3 additions & 7 deletions src/components/Blockie.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@ import { useMoralis } from "react-moralis";
*/

function Blockie(props) {
const { account } = useMoralis();
if (!props.address && !account) return <Skeleton.Avatar active size={40} />;
const { account, isAuthenticated } = useMoralis();
if (!props.address && (!account || !isAuthenticated)) return <Skeleton.Avatar active size={40} />;

return (
<Blockies
seed={props.currentWallet ? account.toLowerCase() : props.address.toLowerCase()}
className="identicon"
{...props}
/>
<Blockies seed={props.currentWallet ? account.toLowerCase() : props.address.toLowerCase()} className="identicon" {...props} />
);
}

Expand Down
5 changes: 3 additions & 2 deletions src/components/Chains/Chains.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useState } from "react";
import { Menu, Dropdown, Button } from "antd";
import { DownOutlined } from "@ant-design/icons";
import { AvaxLogo, PolygonLogo, BSCLogo, ETHLogo } from "./Logos";
import { useChain } from "react-moralis";
import { useChain, useMoralis } from "react-moralis";

const styles = {
item: {
Expand Down Expand Up @@ -85,6 +85,7 @@ const menuItems = [

function Chains() {
const { switchNetwork, chainId, chain } = useChain();
const { isAuthenticated } = useMoralis();
const [selected, setSelected] = useState({});

console.log("chain", chain);
Expand All @@ -111,7 +112,7 @@ function Chains() {
</Menu>
);

if (!chainId) return null;
if (!chainId || !isAuthenticated) return null;

return (
<div>
Expand Down
5 changes: 4 additions & 1 deletion src/components/NativeBalance.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { useNativeBalance } from "react-moralis";
import { useMoralis, useNativeBalance } from "react-moralis";

function NativeBalance(props) {
const { data: balance } = useNativeBalance(props);
const { account, isAuthenticated } = useMoralis();

if (!account || !isAuthenticated) return null;

return <div style={{ textAlign: "center", whiteSpace: "nowrap" }}>{balance.formatted}</div>;
}
Expand Down

0 comments on commit 07bffdb

Please sign in to comment.