Made everything a bit more consistent.

This commit is contained in:
zenodeapp 2023-12-01 16:43:06 +01:00
parent 5737bc6a33
commit ccf63cd413
2 changed files with 13 additions and 13 deletions

View File

@ -111,8 +111,9 @@ const fetchAvatar = (identity: string) => {
}); });
}; };
const loadAvatar = () => { const loadAvatar = (identity: string) => {
fetchAvatar(identity.value).then(() => { // fetches avatar from keybase and stores it in localStorage
fetchAvatar(identity).then(() => {
localStorage.setItem('avatars', JSON.stringify(avatars.value)); localStorage.setItem('avatars', JSON.stringify(avatars.value));
}); });
}; };
@ -122,7 +123,7 @@ onMounted(() => {
staking.fetchValidator(validator).then((res) => { staking.fetchValidator(validator).then((res) => {
v.value = res.validator; v.value = res.validator;
identity.value = res.validator?.description?.identity || ''; identity.value = res.validator?.description?.identity || '';
if (identity.value && !avatars.value[identity.value]) loadAvatar(); if (identity.value && !avatars.value[identity.value]) loadAvatar(identity.value);
const prefix = valoperToPrefix(v.value.operator_address) || '<Invalid>'; const prefix = valoperToPrefix(v.value.operator_address) || '<Invalid>';
addresses.value.hex = consensusPubkeyToHexAddress( addresses.value.hex = consensusPubkeyToHexAddress(
@ -208,7 +209,7 @@ function pageload(p: number) {
class="object-contain" class="object-contain"
@error=" @error="
(e) => { (e) => {
loadAvatar(); loadAvatar(identity);
} }
" "
/> />

View File

@ -164,17 +164,15 @@ const fetchAvatar = (identity: string) => {
}); });
}; };
const loadAvatar = (validator: Validator) => { const loadAvatar = (identity: string) => {
const identity = validator.description?.identity; // fetches avatar from keybase and stores it in localStorage
if (identity) {
fetchAvatar(identity).then(() => { fetchAvatar(identity).then(() => {
localStorage.setItem('avatars', JSON.stringify(avatars.value)); localStorage.setItem('avatars', JSON.stringify(avatars.value));
}); });
}
}; };
const loadAvatars = () => { const loadAvatars = () => {
// fetches all avatars from keybase and stores it in localStorage
const promises = staking.validators.map((validator) => { const promises = staking.validators.map((validator) => {
const identity = validator.description?.identity; const identity = validator.description?.identity;
@ -340,7 +338,8 @@ loadAvatars();
class="object-contain" class="object-contain"
@error=" @error="
(e) => { (e) => {
loadAvatar(v); const identity = v.description?.identity;
if (identity) loadAvatar(identity);
} }
" "
/> />