Skip to content

Commit

Permalink
Merge pull request #248 from aeternity/feature/set-active-name
Browse files Browse the repository at this point in the history
Set active name
  • Loading branch information
mradkov authored Apr 30, 2020
2 parents 5e3cb5b + 041305b commit e543af0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
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
2 changes: 2 additions & 0 deletions src/popup/router/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ export default [
{
path: '/names',
component: Names,
props: true,
name: 'names',
meta: {
title: 'names',
},
Expand Down
20 changes: 13 additions & 7 deletions src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@ export default {
commit(types.UPDATE_LATEST_TRANSACTIONS, payload);
},
setAccountName({ commit }, payload) {
commit(types.SET_ACCOUNT_NAME, payload);
commit(types.SET_ACCOUNT_AENS, {
account: 0,
aename: payload.name,
pending: false,
});
},
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 @@ -114,11 +118,13 @@ export default {
names = uniqBy(names, 'name');
if (!process.env.RUNNING_IN_TESTS) {
if (names.length) {
commit(types.SET_ACCOUNT_AENS, {
account: index,
aename: names[0].name,
pending: !!names[0].pending,
});
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
2 changes: 1 addition & 1 deletion src/store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default {
state.subaccounts[payload.account].balance = payload.balance;
},
[types.SET_ACCOUNT_NAME](state, payload) {
state.subaccounts[state.activeAccount].name = payload;
state.subaccounts[state.activeAccount].aename = payload;
},
[types.SET_ACCOUNT_AENS](state, { account, aename, pending }) {
state.subaccounts[account].aename = aename;
Expand Down

1 comment on commit e543af0

@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.