Skip to content

Commit

Permalink
Handle properly the display of "Loading…" and "No Data" in VerifiedCo…
Browse files Browse the repository at this point in the history
…ntractTable.

Signed-off-by: Simon Viénot <[email protected]>
  • Loading branch information
svienot committed Feb 20, 2024
1 parent 16eb4d6 commit 4ebe2c1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/components/EmptyTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<template>
<div class="has-text-centered h-is-tertiary-text-text has-text-grey mb-4">
<span v-if="initialLoading">Loading…</span>
<span v-if="initialLoading || loading">Loading…</span>
<span v-else>No Data</span>
</div>
</template>
Expand All @@ -41,6 +41,13 @@ import {initialLoadingKey} from "@/AppKeys";
export default defineComponent({
name: "EmptyTable",

props: {
loading: {
type: Boolean,
default: false
}
},

setup() {
const initialLoading = inject(initialLoadingKey, ref(false))
return { initialLoading }
Expand Down
3 changes: 2 additions & 1 deletion src/components/contract/VerifiedContractTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

</o-table>

<EmptyTable v-if="contracts.length === 0"/>
<EmptyTable v-if="contracts.length === 0" :loading="!loaded"/>

</template>

Expand Down Expand Up @@ -122,6 +122,7 @@ export default defineComponent({
handleClick,
ORUGA_MOBILE_BREAKPOINT,
contracts,
loaded: props.contractsLookup.loaded
}
}
});
Expand Down
4 changes: 4 additions & 0 deletions src/utils/cache/VerifiedContractsCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ export class VerifiedContractsLookup extends SingletonLookup<Contract[]> impleme
private refreshCount = 0
private autoRefreshRef: Ref<boolean> = ref(true)

public loaded = ref(false)

constructor(cache: VerifiedContractsCache) {
super(cache)
}
Expand All @@ -134,10 +136,12 @@ export class VerifiedContractsLookup extends SingletonLookup<Contract[]> impleme
this.scheduleNextRefresh()
}
this.entity.value = await this.cache.lookup()
this.loaded.value = true
}

public unmount(): void {
this.entity.value = null
this.loaded.value = false
if (this.timeoutID != -1) {
window.clearTimeout(this.timeoutID)
this.timeoutID = -1
Expand Down

0 comments on commit 4ebe2c1

Please sign in to comment.