Skip to content

Commit

Permalink
show a name if no activated
Browse files Browse the repository at this point in the history
  • Loading branch information
vmangelovv committed Apr 30, 2020
1 parent b115c61 commit 4f0bcf2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
12 changes: 1 addition & 11 deletions src/popup/router/components/AccountInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
<div class="title">
<div class="account-name" data-cy="account-name">
<template v-if="chainName">{{ activeAccountName }}</template>
<router-link to="/names" v-if="!availNames">Claim your .chain name</router-link>
<router-link
:to="{ name: 'names', params: { activateName: availNames } }"
v-if="availNames && !chainName"
>Set your active name</router-link
>
<router-link to="/names" v-else>Claim your .chain name</router-link>
</div>
<div class="copied-alert" v-if="copied">{{ $t('pages.account.copied') }}</div>
<button data-cy="copy" @click="copy" v-clipboard:copy="account.publicKey">
Expand All @@ -31,18 +26,13 @@ export default {
components: { Copyicon, UserAvatar },
data: () => ({
copied: false,
availNames: false,
}),
computed: {
...mapGetters(['account', 'activeAccountName']),
chainName() {
return this.activeAccountName.includes('.chain');
},
},
created() {
const { names } = this.$store.state;
this.availNames = !!names.length;
},
methods: {
copy() {
this.copied = true;
Expand Down
2 changes: 0 additions & 2 deletions src/popup/router/pages/Names.vue
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ import UserAvatar from '../components/UserAvatar';
import Badge from '../components/Badge';
export default {
props: ['activateName'],
components: {
Input,
Button,
Expand Down Expand Up @@ -282,7 +281,6 @@ export default {
},
},
created() {
if (this.activateName) this.tab = 'registered';
this.loading = true;
this.polling = setInterval(async () => {
if (!this.middleware) {
Expand Down
12 changes: 10 additions & 2 deletions src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default {
initSdk({ commit }, payload) {
commit(types.INIT_SDK, payload);
},
async getRegisteredNames({ commit, state, dispatch }) {
async getRegisteredNames({ commit, state, getters, dispatch }) {
if (!state.middleware) return;
const { middlewareUrl } = state.network[state.current.network];
const res = await Promise.all(
Expand Down Expand Up @@ -117,7 +117,15 @@ export default {
names = flatten(names);
names = uniqBy(names, 'name');
if (!process.env.RUNNING_IN_TESTS) {
if (!names.length) {
if (names.length) {
if (!getters.activeAccountName.includes('.chain')) {
commit(types.SET_ACCOUNT_AENS, {
account: index,
aename: names[0].name,
pending: !!names[0].pending,
});
}
} else {
commit(types.SET_ACCOUNT_AENS, { account: index, aename: null, pending: false });
}
}
Expand Down

1 comment on commit 4f0bcf2

@davidyuk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.