Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: validator and account details rendering problem #300

Merged
merged 2 commits into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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