fix: logo loading

This commit is contained in:
liangping 2023-05-17 08:33:44 +08:00
parent 1c44a04cd4
commit fc707e0475
2 changed files with 14 additions and 23 deletions

View File

@ -56,7 +56,6 @@ staking
const txs = ref({} as PaginatedTxs); const txs = ref({} as PaginatedTxs);
blockchain.rpc.getTxsBySender(addresses.value.account).then((x) => { blockchain.rpc.getTxsBySender(addresses.value.account).then((x) => {
console.log('txs', x);
txs.value = x; txs.value = x;
}); });
@ -78,14 +77,19 @@ const selfRate = computed(() => {
} }
return '-'; return '-';
}); });
const logo = (identity?: string) => {
if (!identity) return '';
const url = avatars.value[identity] || '';
return url.startsWith('http')
? url
: `https://s3.amazonaws.com/keybase_processed_uploads/${url}`;
};
onMounted(() => { onMounted(() => {
if (validator) { if (validator) {
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]) { if (identity.value && !avatars.value[identity.value]) {
console.log(identity.value, avatars);
staking.keybase(identity.value).then((d) => { staking.keybase(identity.value).then((d) => {
if (Array.isArray(d.them) && d.them.length > 0) { if (Array.isArray(d.them) && d.them.length > 0) {
const uri = String(d.them[0]?.pictures?.primary?.url).replace( const uri = String(d.them[0]?.pictures?.primary?.url).replace(
@ -144,9 +148,7 @@ onMounted(() => {
<div class="w-24 rounded-lg"> <div class="w-24 rounded-lg">
<img <img
v-if="avatars[identity] !== 'undefined'" v-if="avatars[identity] !== 'undefined'"
v-lazy=" v-lazy="logo(identity)"
`https://s3.amazonaws.com/keybase_processed_uploads/${avatars[identity]}`
"
class="object-contain" class="object-contain"
/> />
<Icon <Icon

View File

@ -58,8 +58,6 @@ async function fetchChange() {
} }
} }
fetchChange();
const changes = computed(() => { const changes = computed(() => {
const changes = {} as Record<string, number>; const changes = {} as Record<string, number>;
Object.keys(latest.value).forEach((k) => { Object.keys(latest.value).forEach((k) => {
@ -92,12 +90,6 @@ const change24Color = (key?: Key) => {
if (v < 0) return 'text-error'; if (v < 0) return 'text-error';
}; };
const update = (m: DebuggerEvent) => {
if (m.key === 'validators') {
loadAvatars();
}
};
const list = computed(() => { const list = computed(() => {
return tab.value === 'active' ? staking.validators : unbondList.value; return tab.value === 'active' ? staking.validators : unbondList.value;
// return staking.validators // return staking.validators
@ -107,11 +99,13 @@ const loadAvatars = () => {
// fetch avatar from keybase // fetch avatar from keybase
let promise = Promise.resolve(); let promise = Promise.resolve();
staking.validators.forEach((item) => { staking.validators.forEach((item) => {
console.log(item.description)
promise = promise.then( promise = promise.then(
() => () =>
new Promise((resolve) => { new Promise((resolve) => {
const identity = item.description?.identity; const identity = item.description?.identity;
if (identity && !avatars.value[identity]) { if (identity && !avatars.value[identity]) {
console.log("loading:", identity)
staking.keybase(identity).then((d) => { staking.keybase(identity).then((d) => {
if (Array.isArray(d.them) && d.them.length > 0) { if (Array.isArray(d.them) && d.them.length > 0) {
const uri = String(d.them[0]?.pictures?.primary?.url).replace( const uri = String(d.them[0]?.pictures?.primary?.url).replace(
@ -136,15 +130,6 @@ const loadAvatars = () => {
}); });
}; };
staking.$subscribe((m, s) => {
if (Array.isArray(m.events)) {
m.events.forEach((x) => {
update(x);
});
} else {
update(m.events);
}
});
const logo = (identity?: string) => { const logo = (identity?: string) => {
if (!identity) return ''; if (!identity) return '';
const url = avatars.value[identity] || ''; const url = avatars.value[identity] || '';
@ -168,6 +153,10 @@ const rank = function (position: number) {
return 'primary'; return 'primary';
} }
}; };
fetchChange();
loadAvatars();
</script> </script>
<template> <template>
<div> <div>