From 3e204c463e2b628c0ac7468df3a1446fd756bb8e Mon Sep 17 00:00:00 2001 From: goosewobbler Date: Sat, 14 Jan 2023 04:16:39 +0000 Subject: [PATCH 1/6] render Accounts if no signer --- app/dash/App.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/dash/App.js b/app/dash/App.js index 64a79c3b2..a1f052846 100644 --- a/app/dash/App.js +++ b/app/dash/App.js @@ -51,7 +51,7 @@ class Dash extends React.Component { if (view === 'accounts') return if (view === 'expandedSigner' && data.signer) { const signer = this.store('main.signers', data.signer) - if (!signer) return null + if (!signer) return return } if (view === 'chains') return From 6704ef65128d04cb0a4e605f68ffb24018aecea0 Mon Sep 17 00:00:00 2001 From: goosewobbler Date: Mon, 16 Jan 2023 20:10:22 +0000 Subject: [PATCH 2/6] nav to accounts instead of rendering accounts --- app/dash/App.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/dash/App.js b/app/dash/App.js index a1f052846..b9dec702f 100644 --- a/app/dash/App.js +++ b/app/dash/App.js @@ -51,7 +51,10 @@ class Dash extends React.Component { if (view === 'accounts') return if (view === 'expandedSigner' && data.signer) { const signer = this.store('main.signers', data.signer) - if (!signer) return + if (!signer) { + link.send('tray:action', 'navDash', { view: 'accounts' }) + return null + } return } if (view === 'chains') return From 24bb0c7030fcbec169751561dad4dd7d8ce64066 Mon Sep 17 00:00:00 2001 From: goosewobbler Date: Mon, 16 Jan 2023 22:28:43 +0000 Subject: [PATCH 3/6] clear nav items for a given signer --- app/dash/App.js | 2 +- main/store/actions/index.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/dash/App.js b/app/dash/App.js index b9dec702f..6915b12aa 100644 --- a/app/dash/App.js +++ b/app/dash/App.js @@ -52,7 +52,7 @@ class Dash extends React.Component { if (view === 'expandedSigner' && data.signer) { const signer = this.store('main.signers', data.signer) if (!signer) { - link.send('tray:action', 'navDash', { view: 'accounts' }) + link.send('tray:action', 'navClearSigner', data.signer) return null } return diff --git a/main/store/actions/index.js b/main/store/actions/index.js index 0c1e2235d..9d3fee888 100644 --- a/main/store/actions/index.js +++ b/main/store/actions/index.js @@ -678,6 +678,9 @@ module.exports = { return win }) }, + navClearSigner: (u, signerId) => { + u('windows.dash.nav', (nav) => nav.filter((navItem) => navItem?.data?.signer !== signerId)) + }, navClearReq: (u, handlerId, showRequestInbox = true) => { u('windows.panel.nav', (nav) => { const newNav = nav.filter((navItem) => { From 9d930eb68b6f9dc140b4bad623802ae5654b0c76 Mon Sep 17 00:00:00 2001 From: goosewobbler Date: Tue, 17 Jan 2023 15:17:47 +0000 Subject: [PATCH 4/6] add test --- test/main/store/actions/index.test.js | 43 ++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/test/main/store/actions/index.test.js b/test/main/store/actions/index.test.js index 9e635e7b6..19891407d 100644 --- a/test/main/store/actions/index.test.js +++ b/test/main/store/actions/index.test.js @@ -22,7 +22,8 @@ import { activateNetwork as activateNetworkAction, setBlockHeight as setBlockHeightAction, updateAccount as updateAccountAction, - navClearReq as clearNavRequestAction + navClearReq as clearNavRequestAction, + navClearSigner as clearNavSignerAction } from '../../../../main/store/actions' import { toTokenId } from '../../../../resources/domain/balance' @@ -1171,6 +1172,45 @@ describe('#removeKnownTokens', () => { }) }) +describe('#navClearSigner', () => { + let nav + + const updaterFn = (node, update) => { + expect(node).toBe('windows.panel.nav') + + nav = update(nav) + } + + const clearSigner = clearNavSignerAction.bind(null, updaterFn) + + beforeEach(() => { + nav = [] + }) + + it('should remove a specific signer from the nav', () => { + nav = [ + { + view: 'expandedSigner', + data: { + signer: '1a' + } + }, + { + view: 'expandedSigner', + data: { + signer: '2b' + } + } + ] + + const [req1, req2] = nav + + clearSigner('2b') + + expect(nav).toStrictEqual([req1]) + }) +}) + describe('#navClearReq', () => { let nav @@ -1236,3 +1276,4 @@ describe('#navClearReq', () => { expect(nav).toStrictEqual([]) }) }) +clearNavSignerAction From 64729e947a043292a045da4fa7c5290aba5d5ade Mon Sep 17 00:00:00 2001 From: goosewobbler Date: Tue, 17 Jan 2023 15:18:40 +0000 Subject: [PATCH 5/6] fix test --- test/main/store/actions/index.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/main/store/actions/index.test.js b/test/main/store/actions/index.test.js index 19891407d..58b41c322 100644 --- a/test/main/store/actions/index.test.js +++ b/test/main/store/actions/index.test.js @@ -1176,7 +1176,7 @@ describe('#navClearSigner', () => { let nav const updaterFn = (node, update) => { - expect(node).toBe('windows.panel.nav') + expect(node).toBe('windows.dash.nav') nav = update(nav) } From fec345bba79d80d1e6f530f8015686eee12a0030 Mon Sep 17 00:00:00 2001 From: goosewobbler Date: Wed, 18 Jan 2023 12:06:03 +0000 Subject: [PATCH 6/6] move navClearSigner invocation --- app/dash/App.js | 4 ---- main/signers/index.ts | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/dash/App.js b/app/dash/App.js index 6915b12aa..a8e8e6086 100644 --- a/app/dash/App.js +++ b/app/dash/App.js @@ -51,10 +51,6 @@ class Dash extends React.Component { if (view === 'accounts') return if (view === 'expandedSigner' && data.signer) { const signer = this.store('main.signers', data.signer) - if (!signer) { - link.send('tray:action', 'navClearSigner', data.signer) - return null - } return } if (view === 'chains') return diff --git a/main/signers/index.ts b/main/signers/index.ts index c62797ee7..ff12c9be3 100644 --- a/main/signers/index.ts +++ b/main/signers/index.ts @@ -112,6 +112,7 @@ class Signers extends EventEmitter { if (signer) { delete this.signers[id] store.removeSigner(id) + store.navClearSigner(id) const type = signer.type === 'ring' || signer.type === 'seed' ? 'hot' : signer.type