Skip to content

Commit

Permalink
fix: show error when failed to load delegates list (#4655)
Browse files Browse the repository at this point in the history
* fix: show error when failed to load delegates list

* chore: better variable name

---------

Co-authored-by: Chaitanya <yourchaitu@gmail.com>
  • Loading branch information
wa0x6e and ChaituVR authored Apr 6, 2024
1 parent 95a87b5 commit 4797e32
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/views/DelegateView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const form = ref({
address: (route.params.to as string) || '',
id: (route.params.key as string) || ''
});
const delegationLoadingError = ref(false);
const { profiles, loadProfiles } = useProfiles();
Expand Down Expand Up @@ -97,6 +98,7 @@ const getDelegationsAndDelegatesLoading = ref(false);
async function getDelegationsAndDelegates() {
if (web3Account.value) {
try {
delegationLoadingError.value = false;
getDelegationsAndDelegatesLoading.value = true;
const [delegatesObj, delegatorsObj] = await Promise.all([
getDelegates(networkKey.value, web3Account.value),
Expand All @@ -108,6 +110,7 @@ async function getDelegationsAndDelegates() {
delegates.value = [];
delegators.value = [];
console.log(error);
delegationLoadingError.value = true;
} finally {
getDelegationsAndDelegatesLoading.value = false;
}
Expand All @@ -124,6 +127,7 @@ async function getDelegatesWithScore() {
);
if (delegationStrategy.length === 0) return;
delegationLoadingError.value = false;
delegatesLoading.value = true;
try {
const delegations: any = await getDelegatesBySpace(
Expand Down Expand Up @@ -166,6 +170,7 @@ async function getDelegatesWithScore() {
delegatesLoading.value = false;
} catch (e) {
delegatesLoading.value = false;
delegationLoadingError.value = true;
console.log(e);
return e;
}
Expand Down Expand Up @@ -327,7 +332,6 @@ onMounted(async () => {
/>
</div>
</BaseBlock>

<BaseBlock
v-if="space?.id && specifySpaceChecked"
:title="$tc('delegate.topDelegates')"
Expand Down Expand Up @@ -357,8 +361,16 @@ onMounted(async () => {
"
/>
</div>

<div
v-if="delegationLoadingError"
class="mx-4 flex items-center py-3 text-red"
>
<BaseIcon name="warning" class="mr-1" /> Error while retrieving the
delegates list
</div>
<div
v-if="!delegatesLoading && delegatesWithScore.length < 1"
v-else-if="!delegatesLoading && delegatesWithScore.length < 1"
class="mx-4 flex items-center py-3"
>
{{ $tc('delegate.noDelegatesFoundFor', [space.id]) }}
Expand Down

0 comments on commit 4797e32

Please sign in to comment.