Skip to content

Commit

Permalink
fix: Refactor notExistent variables (#599)
Browse files Browse the repository at this point in the history
  • Loading branch information
janmichek authored Dec 11, 2023
1 parent 1004010 commit a115b2d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/components/AccountDetailsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class="u-hidden-desktop"/>
</template>
<p
v-if="accountDetails.notExistent"
v-if="accountDetails.isExistent === false"
class="account-details-panel__not-existent">
The account has never been seen in the network.
<br>
Expand Down
6 changes: 3 additions & 3 deletions src/components/KeyblockDetailsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
DETAILS
</template>
<template #header>
<div v-if="!keyblockDetails.notExistent">
<div v-if="!!keyblockDetails.isExistent">
<copy-chip
:label="keyblockDetails.hash"
class="u-hidden-mobile"/>
Expand All @@ -15,7 +15,7 @@
</div>
</template>
<p
v-if="keyblockDetails.notExistent"
v-if="keyblockDetails.isExistent === false"
class="keyblock-details-panel__not-existent">
Requested keyblock has never been seen in the network.
<br>
Expand Down Expand Up @@ -230,7 +230,7 @@ const isNextKeyblockMined = computed(() =>
}
&__not-existent {
margin: var(--space-3) 0;
margin: 0 0 var(--space-3) 0;
}
&__controls {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/accounts/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ const { fetchAccount } = accountStore
const route = useRoute()
const isTabsVisible = computed(() => process.client &&
((accountDetails.value && !accountDetails.value?.notExistent) ||
((accountDetails.value && !!accountDetails.value.isExistent) ||
!!accountTokens.value?.data.length))
const isTokensTabSelected = computed(() => process.client &&
accountDetails.value?.notExistent &&
accountDetails.value?.isExistent === false &&
!!accountTokens.value?.data.length)
const activeTabIndex = computed({
Expand Down
13 changes: 2 additions & 11 deletions src/pages/keyblocks/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,13 @@ const route = useRoute()
const { isLoading } = useLoading()
const isKeyblockExistent = computed(() => keyblockDetails.value && !keyblockDetails.value.notExistent)
const isKeyblockExistent = computed(() => keyblockDetails.value && !!keyblockDetails.value.isExistent)
const { error } = await useAsyncData(async() => {
await useAsyncData(async() => {
await fetchKeyblock(route.params.id)
return true
})
if (error.value) {
throw showError({
data: {
entityId: route.params.id,
entityName: 'Keyblock',
},
statusMessage: 'EntityDetailsNotFound',
})
}
</script>

<style scoped>
Expand Down
2 changes: 1 addition & 1 deletion src/stores/accountDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const useAccountStore = defineStore('account', () => {
rawAccountDetails.value = data
} catch (e) {
if ([400, 404].includes(e.response.status)) {
rawAccountDetails.value = { id: accountId, notExistent: true }
rawAccountDetails.value = { id: accountId, isExistent: false }
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/stores/keyblockDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const useKeyblockDetailsStore = defineStore('keyblockDetails', () => {
rawKeyblock.value = data
} catch (error) {
if (error.response?.status === 404) {
rawKeyblock.value = { notExistent: true }
rawKeyblock.value = { isExistent: false }
return
}
throw error
Expand Down

0 comments on commit a115b2d

Please sign in to comment.