Skip to content

Commit

Permalink
fix: don't query for empty account string, update account tab on brow…
Browse files Browse the repository at this point in the history
…ser navigation
  • Loading branch information
donnyquixotic committed Feb 7, 2024
1 parent a388e77 commit 65ccb34
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/api/eosio_core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ const eosioCore = new APIClient({
export const getAccount = async function (
address: string,
): Promise<API.v1.AccountObject> {
return await eosioCore.v1.chain.get_account(address);
if (address){
return await eosioCore.v1.chain.get_account(address);
}
};

export const getKeyAccounts = async function (
Expand Down
27 changes: 17 additions & 10 deletions src/pages/Account.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,39 @@ export default defineComponent({
onMounted(async () => {
await store.dispatch('account/updateABI', route.params.account);
if (route.query.tab !== tab.value) {
await updateQueryParams();
}
});
watch([account], async () => {
await store.dispatch('account/updateABI', route.params.account);
});
const onChangeTab = async (newTab: string) => {
await router.push({
// taking care to preserve the current #hash anchor and the current query parameters
hash: window.location.hash,
query: {
...route.query,
tab:newTab,
},
});
const updateQueryParams = async () => {
debugger;
await router.replace({ query: { tab: tab.value } });
};
const onChangeTab = (newTab: string) => {
tab.value = newTab;
};
watch([tab], () => {
void router.push({
path: router.currentRoute.value.path,
query: {
tab: tab.value,
},
});
});
watch(route, () => {
// handle tab update on browser navigation
if (route.path.includes('/account/') && route.query.tab !== tab.value){
onChangeTab(route.query.tab as string);
}
});
return {
onChangeTab,
tab,
Expand Down
4 changes: 4 additions & 0 deletions src/store/resources/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export const actions: ActionTree<ResourcesStateInterface, StateInterface> = {

const accountData = store.rootState.account.data;

if (!accountData) {
return;
}

// self staked resources
const self_net_weight = Number(accountData.self_delegated_bandwidth?.net_weight.value ?? 0);
const self_cpu_weight = Number(accountData.self_delegated_bandwidth?.cpu_weight.value ?? 0);
Expand Down

0 comments on commit 65ccb34

Please sign in to comment.