1
0
Fork 0
forked from lthn/blockchain

prevent double click & ngZone on navigate

This commit is contained in:
wildkif 2019-02-18 17:44:34 +02:00
parent 474d17efc6
commit a402683638
8 changed files with 40 additions and 17 deletions

View file

@ -96,7 +96,9 @@ export class AssignAliasComponent implements OnInit {
// service.unconfirmed_aliases.push({tx_hash: data.tx_hash, name: this.alias.name});
// wallet.wakeAlias = true;
this.modalService.prepareModal('info', 'ASSIGN_ALIAS.REQUEST_ADD_REG');
this.router.navigate(['/wallet/' + this.wallet.wallet_id]);
this.ngZone.run(() => {
this.router.navigate(['/wallet/' + this.wallet.wallet_id]);
});
}
});
}

View file

@ -49,7 +49,9 @@ export class CreateWalletComponent implements OnInit {
}
createWallet() {
this.router.navigate(['/seed-phrase'], {queryParams: {wallet_id: this.wallet.id}});
this.ngZone.run(() => {
this.router.navigate(['/seed-phrase'], {queryParams: {wallet_id: this.wallet.id}});
});
}
saveWallet() {

View file

@ -1,4 +1,4 @@
import {Component, OnInit} from '@angular/core';
import {Component, NgZone, OnInit} from '@angular/core';
import {Location} from '@angular/common';
import {Router} from '@angular/router';
import {BackendService} from "../_helpers/services/backend.service";
@ -17,13 +17,15 @@ export class EditAliasComponent implements OnInit {
alias: any;
oldAliasComment: 'string';
notEnoughMoney: boolean;
requestProcessing = false;
constructor(
private location: Location,
private router: Router,
private backend: BackendService,
private variablesService: VariablesService,
private modalService: ModalService
private modalService: ModalService,
private ngZone: NgZone
) {}
ngOnInit() {
@ -39,15 +41,19 @@ export class EditAliasComponent implements OnInit {
}
updateAlias() {
if (this.notEnoughMoney || this.oldAliasComment === this.alias.comment) {
if (this.requestProcessing || this.notEnoughMoney || this.oldAliasComment === this.alias.comment) {
return;
}
this.requestProcessing = true;
this.backend.updateAlias(this.wallet.wallet_id, this.alias, this.variablesService.default_fee, (status) => {
if (status) {
this.modalService.prepareModal('success', '');
this.router.navigate(['/wallet/' + this.wallet.wallet_id]);
this.wallet.alias['comment'] = this.alias.comment;
this.ngZone.run(() => {
this.router.navigate(['/wallet/' + this.wallet.wallet_id]);
});
}
this.requestProcessing = false;
});
}

View file

@ -51,7 +51,9 @@ export class RestoreWalletComponent implements OnInit {
createWallet() {
this.router.navigate(['/seed-phrase'], {queryParams: {wallet_id: this.wallet.id}});
this.ngZone.run(() => {
this.router.navigate(['/seed-phrase'], {queryParams: {wallet_id: this.wallet.id}});
});
}
saveWallet() {

View file

@ -1,4 +1,4 @@
import {Component, OnInit, OnDestroy} from '@angular/core';
import {Component, NgZone, OnInit, OnDestroy} from '@angular/core';
import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
import {VariablesService} from '../_helpers/services/variables.service';
@ -15,9 +15,9 @@ export class SidebarComponent implements OnInit, OnDestroy {
constructor(
private route: ActivatedRoute,
private router: Router,
private variablesService: VariablesService
) {
}
private variablesService: VariablesService,
private ngZone: NgZone
) {}
ngOnInit() {
if (this.router.url.indexOf('/wallet/') !== -1) {
@ -54,7 +54,9 @@ export class SidebarComponent implements OnInit, OnDestroy {
logOut() {
this.variablesService.stopCountdown();
this.variablesService.appPass = '';
this.router.navigate(['/login'], {queryParams: {type: 'auth'}});
this.ngZone.run(() => {
this.router.navigate(['/login'], {queryParams: {type: 'auth'}});
});
}
}

View file

@ -20,6 +20,7 @@ export class TransferAliasComponent implements OnInit {
transferAddressAlias: boolean;
permissionSend: boolean;
notEnoughMoney: boolean;
processingRequst = false;
constructor(
private location: Location,
@ -80,9 +81,10 @@ export class TransferAliasComponent implements OnInit {
}
transferAlias() {
if (!this.permissionSend || !this.transferAddressValid || this.notEnoughMoney) {
if (this.processingRequst || !this.permissionSend || !this.transferAddressValid || this.notEnoughMoney) {
return;
}
this.processingRequst = true;
const newAlias = {
name: this.alias.name,
address: this.transferAddress,
@ -91,10 +93,13 @@ export class TransferAliasComponent implements OnInit {
};
this.backend.updateAlias(this.wallet.wallet_id, newAlias, this.variablesService.default_fee, (status, data) => {
if (status && data.hasOwnProperty('success') && data.success) {
this.modalService.prepareModal('info', 'TRANSFER_ALIAS.REQUEST_SEND_REG')
this.modalService.prepareModal('info', 'TRANSFER_ALIAS.REQUEST_SEND_REG');
this.ngZone.run(() => {
this.router.navigate(['/wallet/' + this.wallet.wallet_id]);
});
}
this.processingRequst = false;
});
this.router.navigate(['/wallet/' + this.wallet.wallet_id]);
}
back() {

View file

@ -59,7 +59,9 @@ export class WalletDetailsComponent implements OnInit, OnDestroy {
onSubmitEdit() {
if (this.detailsForm.value) {
this.variablesService.currentWallet.name = this.detailsForm.get('name').value;
this.router.navigate(['/wallet/' + this.variablesService.currentWallet.wallet_id]);
this.ngZone.run(() => {
this.router.navigate(['/wallet/' + this.variablesService.currentWallet.wallet_id]);
});
}
}

View file

@ -90,7 +90,9 @@ export class WalletComponent implements OnInit, OnDestroy {
tab.active = false;
});
this.tabs[index].active = true;
this.router.navigate(['wallet/' + this.walletID + this.tabs[index].link]);
this.ngZone.run( () => {
this.router.navigate(['wallet/' + this.walletID + this.tabs[index].link]);
});
}
copyAddress() {