From 3f6411971df37a74ad9b7e6b69f1ff6fc6402308 Mon Sep 17 00:00:00 2001 From: kyranjamie Date: Thu, 12 Nov 2020 22:11:58 +0100 Subject: [PATCH] fix: reload app on clear wallet --- app/main.dev.ts | 7 ++++--- app/modals/reset-wallet/reset-wallet-modal.tsx | 3 +-- app/pages/onboarding/05-secret-key/secret-key.tsx | 4 ++-- app/preload.js | 4 +++- app/types/index.ts | 2 ++ 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/main.dev.ts b/app/main.dev.ts index 51dd15333..374fe360d 100644 --- a/app/main.dev.ts +++ b/app/main.dev.ts @@ -24,9 +24,6 @@ import contextMenu from 'electron-context-menu'; import MenuBuilder from './menu'; import { deriveKey } from './crypto/key-generation'; import Store from 'electron-store'; -import TransportNodeHid from '@ledgerhq/hw-transport-node-hid'; -import { safeAwait } from './utils/safe-await'; -import BlockstackApp, { LedgerError } from '@zondax/ledger-blockstack'; // CSP enabled in production mode, don't warn in development delete process.env.ELECTRON_ENABLE_SECURITY_WARNINGS; @@ -191,3 +188,7 @@ ipcMain.on('store-getEntireStore', event => { ipcMain.handle('derive-key', async (_e, args) => { return deriveKey(args); }); + +ipcMain.handle('reload-app', (_e, args) => { + mainWindow?.reload(); +}); diff --git a/app/modals/reset-wallet/reset-wallet-modal.tsx b/app/modals/reset-wallet/reset-wallet-modal.tsx index d7df998db..8b82cf58e 100644 --- a/app/modals/reset-wallet/reset-wallet-modal.tsx +++ b/app/modals/reset-wallet/reset-wallet-modal.tsx @@ -1,7 +1,6 @@ import React, { FC, useState, useRef } from 'react'; import { Modal, ButtonGroup, Button, Box } from '@blockstack/ui'; import { TxModalHeader, TxModalFooter } from '../transaction/transaction-modal-layout'; -// import { remote } from 'electron'; import { clearDiskStorage } from '@utils/disk-store'; import { useHotkeys } from 'react-hotkeys-hook'; @@ -32,7 +31,7 @@ export const ResetWalletModal: FC = ({ isOpen, onClose }) cancelBtnRef.current?.focus(); timer.current = setTimeout(() => { clearDiskStorage(); - // remote.getCurrentWindow().reload(); + api.reloadApp(); }, PANIC_CANCEL_TIME); }; diff --git a/app/pages/onboarding/05-secret-key/secret-key.tsx b/app/pages/onboarding/05-secret-key/secret-key.tsx index aa4f34151..823f82d52 100644 --- a/app/pages/onboarding/05-secret-key/secret-key.tsx +++ b/app/pages/onboarding/05-secret-key/secret-key.tsx @@ -42,8 +42,8 @@ export const SecretKey: React.FC = () => { {mnemonic} - diff --git a/app/preload.js b/app/preload.js index 74d01349b..d14f51fa2 100644 --- a/app/preload.js +++ b/app/preload.js @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-var-requires */ const fs = require('fs'); -const { contextBridge, ipcRenderer, app, shell } = require('electron'); +const { contextBridge, ipcRenderer, app, shell, remote } = require('electron'); const TransportNodeHid = require('@ledgerhq/hw-transport-node-hid').default; @@ -58,6 +58,8 @@ contextBridge.exposeInMainWorld('api', { openExternalLink: url => shell.openExternal(url), + reloadApp: () => ipcRenderer.invoke('reload-app'), + nodeHid: { listen: observer => TransportNodeHid.listen(observer), open: async ({ descriptor, onDisconnect }) => { diff --git a/app/types/index.ts b/app/types/index.ts index ca8d86403..65db74a86 100644 --- a/app/types/index.ts +++ b/app/types/index.ts @@ -22,6 +22,8 @@ declare const api: { openExternalLink(url: string): Promise; + reloadApp(): void; + nodeHid: { listen: typeof import('@ledgerhq/hw-transport').default['listen']; open({