Skip to content

Commit

Permalink
fix: validator and account details rendering problem (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuash authored Sep 10, 2021
1 parent a1a37cf commit fe22b3e
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 66 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Add License to footer ([\#287](https://github.com/forbole/big-dipper-2.0-cosmos/issues/287))
- Changed position of desmos profile
- Fix avatar images not loading correctly ([\#296](https://github.com/forbole/big-dipper-2.0-cosmos/issues/296))
- Fix rendering issue on account and validtor details page ([\#297](https://github.com/forbole/big-dipper-2.0-cosmos/issues/297))

# base-v1.0.9 - 2021-09-03

Expand Down
4 changes: 1 addition & 3 deletions src/components/avatar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ const Avatar: React.FC<{
const icon = useRef(null);
const [error, setError] = useState<boolean>(false);
useEffect(() => {
if (!imageUrl) {
jdenticon.update(icon.current, address);
}
jdenticon.update(icon.current, address);
}, [address, error, imageUrl]);

const handleError = () => {
Expand Down
5 changes: 1 addition & 4 deletions src/screens/account_details/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,7 @@ export const useAccountDetails = () => {
});

useEffect(() => {
handleSetState({
loading: true,
exists: true,
});
handleSetState(initialState);
if (chainConfig.extra.desmosProfile) {
fetchDesmosProfile(R.pathOr('', ['query', 'address'], router));
}
Expand Down
117 changes: 58 additions & 59 deletions src/screens/validator_details/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,68 +24,70 @@ import {
} from '@models';
import { ValidatorDetailsState } from './types';

const initialState = {
loading: true,
exists: true,
desmosProfile: null,
overview: {
validator: {
imageUrl: '',
moniker: '',
},
operatorAddress: '',
selfDelegateAddress: '',
description: '',
website: '',
},
status: {
status: 0,
jailed: false,
condition: 0,
commission: 0,
missedBlockCounter: 0,
signedBlockWindow: 0,
lastSeen: '',
},
votingPower: {
height: 0,
overall: {
value: 0,
denom: '',
},
self: 0,
selfDelegatePercent: 0,
selfDelegate: {
value: 0,
denom: '',
},
},
delegations: {
count: 0,
data: [],
},
redelegations: {
count: 0,
data: [],
},
undelegations: {
count: 0,
data: [],
},
transactions: {
data: [],
hasNextPage: false,
isNextPageLoading: false,
offsetCount: 0,
},
};

export const useValidatorDetails = () => {
const router = useRouter();
const {
findAddress,
findOperator,
validatorToDelegatorAddress,
} = useChainContext();
const [state, setState] = useState<ValidatorDetailsState>({
loading: true,
exists: true,
desmosProfile: null,
overview: {
validator: {
imageUrl: '',
moniker: '',
},
operatorAddress: '',
selfDelegateAddress: '',
description: '',
website: '',
},
status: {
status: 0,
jailed: false,
condition: 0,
commission: 0,
missedBlockCounter: 0,
signedBlockWindow: 0,
lastSeen: '',
},
votingPower: {
height: 0,
overall: {
value: 0,
denom: '',
},
self: 0,
selfDelegatePercent: 0,
selfDelegate: {
value: 0,
denom: '',
},
},
delegations: {
count: 0,
data: [],
},
redelegations: {
count: 0,
data: [],
},
undelegations: {
count: 0,
data: [],
},
transactions: {
data: [],
hasNextPage: false,
isNextPageLoading: false,
offsetCount: 0,
},
});
const [state, setState] = useState<ValidatorDetailsState>(initialState);

const handleSetState = (stateChange: any) => {
setState((prevState) => R.mergeDeepLeft(stateChange, prevState));
Expand All @@ -105,10 +107,7 @@ export const useValidatorDetails = () => {
});

useEffect(() => {
handleSetState({
loading: true,
exists: true,
});
handleSetState(initialState);
if (chainConfig.extra.desmosProfile) {
const address = validatorToDelegatorAddress(R.pathOr('', ['query', 'address'], router));

Expand Down

0 comments on commit fe22b3e

Please sign in to comment.