From a4026836384790a445da3af4f71af8c1ca0fdec5 Mon Sep 17 00:00:00 2001 From: wildkif Date: Mon, 18 Feb 2019 17:44:34 +0200 Subject: [PATCH] prevent double click & ngZone on navigate --- .../src/app/assign-alias/assign-alias.component.ts | 4 +++- .../app/create-wallet/create-wallet.component.ts | 4 +++- .../src/app/edit-alias/edit-alias.component.ts | 14 ++++++++++---- .../app/restore-wallet/restore-wallet.component.ts | 4 +++- .../src/app/sidebar/sidebar.component.ts | 12 +++++++----- .../app/transfer-alias/transfer-alias.component.ts | 11 ++++++++--- .../app/wallet-details/wallet-details.component.ts | 4 +++- .../html_source/src/app/wallet/wallet.component.ts | 4 +++- 8 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/gui/qt-daemon/html_source/src/app/assign-alias/assign-alias.component.ts b/src/gui/qt-daemon/html_source/src/app/assign-alias/assign-alias.component.ts index 91df7489..ed32b89a 100644 --- a/src/gui/qt-daemon/html_source/src/app/assign-alias/assign-alias.component.ts +++ b/src/gui/qt-daemon/html_source/src/app/assign-alias/assign-alias.component.ts @@ -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]); + }); } }); } diff --git a/src/gui/qt-daemon/html_source/src/app/create-wallet/create-wallet.component.ts b/src/gui/qt-daemon/html_source/src/app/create-wallet/create-wallet.component.ts index 33c61245..54abea4f 100644 --- a/src/gui/qt-daemon/html_source/src/app/create-wallet/create-wallet.component.ts +++ b/src/gui/qt-daemon/html_source/src/app/create-wallet/create-wallet.component.ts @@ -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() { diff --git a/src/gui/qt-daemon/html_source/src/app/edit-alias/edit-alias.component.ts b/src/gui/qt-daemon/html_source/src/app/edit-alias/edit-alias.component.ts index ed40b660..3c817014 100644 --- a/src/gui/qt-daemon/html_source/src/app/edit-alias/edit-alias.component.ts +++ b/src/gui/qt-daemon/html_source/src/app/edit-alias/edit-alias.component.ts @@ -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; }); } diff --git a/src/gui/qt-daemon/html_source/src/app/restore-wallet/restore-wallet.component.ts b/src/gui/qt-daemon/html_source/src/app/restore-wallet/restore-wallet.component.ts index 4ac5e156..d69ea586 100644 --- a/src/gui/qt-daemon/html_source/src/app/restore-wallet/restore-wallet.component.ts +++ b/src/gui/qt-daemon/html_source/src/app/restore-wallet/restore-wallet.component.ts @@ -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() { diff --git a/src/gui/qt-daemon/html_source/src/app/sidebar/sidebar.component.ts b/src/gui/qt-daemon/html_source/src/app/sidebar/sidebar.component.ts index 7d129564..4d9ac389 100644 --- a/src/gui/qt-daemon/html_source/src/app/sidebar/sidebar.component.ts +++ b/src/gui/qt-daemon/html_source/src/app/sidebar/sidebar.component.ts @@ -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'}}); + }); } } diff --git a/src/gui/qt-daemon/html_source/src/app/transfer-alias/transfer-alias.component.ts b/src/gui/qt-daemon/html_source/src/app/transfer-alias/transfer-alias.component.ts index 470fba2e..e2bd0bd5 100644 --- a/src/gui/qt-daemon/html_source/src/app/transfer-alias/transfer-alias.component.ts +++ b/src/gui/qt-daemon/html_source/src/app/transfer-alias/transfer-alias.component.ts @@ -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() { diff --git a/src/gui/qt-daemon/html_source/src/app/wallet-details/wallet-details.component.ts b/src/gui/qt-daemon/html_source/src/app/wallet-details/wallet-details.component.ts index 4f356ef9..6ca22ff7 100644 --- a/src/gui/qt-daemon/html_source/src/app/wallet-details/wallet-details.component.ts +++ b/src/gui/qt-daemon/html_source/src/app/wallet-details/wallet-details.component.ts @@ -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]); + }); } } diff --git a/src/gui/qt-daemon/html_source/src/app/wallet/wallet.component.ts b/src/gui/qt-daemon/html_source/src/app/wallet/wallet.component.ts index 72f56a69..190b7aa3 100644 --- a/src/gui/qt-daemon/html_source/src/app/wallet/wallet.component.ts +++ b/src/gui/qt-daemon/html_source/src/app/wallet/wallet.component.ts @@ -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() {