From 7cca7ace2ea4cd4b9d3a242067c9a7c344406aba Mon Sep 17 00:00:00 2001 From: brunobar79 Date: Mon, 9 Jul 2018 17:24:52 -0400 Subject: fix all the account related bugs --- app/scripts/metamask-controller.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index d70bac1c3..8104374bc 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -529,17 +529,28 @@ module.exports = class MetamaskController extends EventEmitter { switch (deviceName) { case 'trezor': const keyringController = this.keyringController + const oldAccounts = await keyringController.getAccounts() let keyring = await keyringController.getKeyringsByType( 'Trezor Hardware' )[0] if (!keyring) { keyring = await this.keyringController.addNewKeyring('Trezor Hardware') } - if (page === 0) { - keyring.page = 0 + let accounts = [] + + switch (page) { + case -1: + accounts = await keyring.getPreviousPage() + break + case 1: + accounts = await keyring.getNextPage() + break + default: + accounts = await keyring.getFirstPage() } - const accounts = page === -1 ? await keyring.getPreviousPage() : await keyring.getNextPage() - this.accountTracker.syncWithAddresses(accounts.map(a => a.address)) + + // Merge with existing accounts + this.accountTracker.syncWithAddresses(oldAccounts.concat(accounts.map(a => a.address))) return accounts default: -- cgit v1.2.3