Skip to content

Commit

Permalink
fix: reload app on clear wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Dec 16, 2020
1 parent 012efab commit 3f64119
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
7 changes: 4 additions & 3 deletions app/main.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
});
3 changes: 1 addition & 2 deletions app/modals/reset-wallet/reset-wallet-modal.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -32,7 +31,7 @@ export const ResetWalletModal: FC<ResetWalletModalProps> = ({ isOpen, onClose })
cancelBtnRef.current?.focus();
timer.current = setTimeout(() => {
clearDiskStorage();
// remote.getCurrentWindow().reload();
api.reloadApp();
}, PANIC_CANCEL_TIME);
};

Expand Down
4 changes: 2 additions & 2 deletions app/pages/onboarding/05-secret-key/secret-key.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export const SecretKey: React.FC = () => {
<Text textStyle="body.small" mt="loose" mx="loose" lineHeight="20px" display="block">
{mnemonic}
</Text>
<Button variant="link" mt="tight">
<Text textStyle="caption.medium" fontSize="12px" onClick={onCopy}>
<Button variant="link" mt="tight" onClick={onCopy}>
<Text textStyle="caption.medium" fontSize="12px">
Copy to clipboard
</Text>
</Button>
Expand Down
4 changes: 3 additions & 1 deletion app/preload.js
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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 }) => {
Expand Down
2 changes: 2 additions & 0 deletions app/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ declare const api: {

openExternalLink(url: string): Promise<void>;

reloadApp(): void;

nodeHid: {
listen: typeof import('@ledgerhq/hw-transport').default['listen'];
open({
Expand Down

0 comments on commit 3f64119

Please sign in to comment.