Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Merge pull request #237 from LiskHQ/218-fix-forgin-tab-visibility
Browse files Browse the repository at this point in the history
Fix forging tab visibility - Closes #218
  • Loading branch information
slaweet authored May 18, 2017
2 parents bfcde3e + bbcc964 commit e1b5461
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
24 changes: 18 additions & 6 deletions src/app/components/delegate-registration/delegateRegistration.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
import './delegateRegistration.less';

app.directive('delegateRegistration', ($mdDialog, delegateService, Account, dialog) => {
app.directive('delegateRegistration', ($mdDialog, delegateService, Account, dialog, $rootScope) => {
const DelegateRegistrationLink = function ($scope, $element) {
function checkPendingRegistration() {
delegateService.getDelegate({
username: $scope.username,
}).then((data) => {
Account.set({
isDelegate: true,
username: data.delegate.username,
});
$scope.pendingRegistrationListener();
});
}

$scope.form = {
name: '',
fee: 25,
error: '',
onSubmit: (form) => {
if (form.$valid) {
$scope.username = $scope.form.name.toLowerCase();
delegateService.registerDelegate(
$scope.form.name.toLowerCase(),
$scope.username,
Account.get().passphrase,
$scope.form.secondPassphrase,
)
.then(() => {
dialog.successAlert({
title: 'Success',
text: 'Account was successfully registered as delegate.',
text: 'Delegate registration was successfully submitted. It can take several seconds before it is confirmed.',
})
.then(() => {
Account.set({
isDelegate: true,
username: $scope.form.name.toLowerCase(),
$scope.pendingRegistrationListener = $rootScope.$on('syncTick', () => {
checkPendingRegistration();
});
$scope.reset(form);
$mdDialog.hide();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ div.dialog-delegate-registration(aria-label='Vote for delegates')
div
md-input-container.md-block
label Delegate name
input(type='text', name='delegateName', ng-model='$ctrl.form.name', required, ng-disabled='$ctrl.loading')
input(type='text', name='delegateName', ng-model='$ctrl.form.name', required, ng-disabled='$ctrl.loading', md-autofocus)
div(ng-messages='delegateRegistrationForm.name.$error')
div(ng-message='required') Required
md-input-container.md-block(ng-if='$ctrl.account.get().secondSignature')
Expand Down
3 changes: 1 addition & 2 deletions src/app/components/forging/forging.pug
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ div.offline-hide
md-content
div(layout='row', ng-if='$ctrl.delegate && !$ctrl.delegate.username')
md-card(flex-100, flex-gt-xs=100, layout-align='center center', layout-padding)
span.title You need to become a delegate to start forging
md-button.md-raised.md-primary(disabled) Become Delegate
span.title You need to become a delegate to start forging. If you already registered to become a delegate, your registration hasn't been processed, yet.
div(layout='column', layout-gt-xs='row', ng-if='$ctrl.delegate.username')
md-card(flex-gt-xs=100, layout-padding)
md-card-title
Expand Down
6 changes: 6 additions & 0 deletions src/app/components/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ app.component('main', {
update() {
return this.accountApi.get(this.account.get().address)
.then((res) => {
if (res.publicKey === null) {
// because res.publicKey is null if the account didn't send any transaction yet,
// but we have the publicKey computed from passphrase
delete res.publicKey;
}

this.account.set(res);
})
.catch((res) => {
Expand Down
2 changes: 1 addition & 1 deletion src/spec/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ function testDelegateRegistration() {
waitForElemAndClickIt('md-dialog button.md-primary');

browser.sleep(500);
checkAlertDialog('Success', 'Account was successfully registered as delegate.');
checkAlertDialog('Success', 'Delegate registration was successfully submitted. It can take several seconds before it is confirmed.');
}

function testForgingCenter() {
Expand Down

0 comments on commit e1b5461

Please sign in to comment.