Skip to content

Commit bd4c109

Browse files
committed
feat(neuron-ui): handle current-wallet update and wallet-list update separately
1 parent 5623f3b commit bd4c109

5 files changed

Lines changed: 12 additions & 6 deletions

File tree

packages/neuron-ui/src/containers/Main/hooks.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,11 @@ export const useSubscription = ({
154154
updateTransaction({ walletID, hash: txHash })
155155
break
156156
}
157-
case 'wallet': {
157+
case 'current-wallet': {
158+
updateCurrentWallet()(dispatch)
159+
break
160+
}
161+
case 'wallets': {
158162
updateWalletList()(dispatch)
159163
updateCurrentWallet()(dispatch)
160164
break

packages/neuron-ui/src/types/Subject/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ declare namespace Subject {
1717
}
1818
interface DataUpdateMetaInfo {
1919
walletID?: string
20-
dataType: 'address' | 'transaction' | 'wallet' | 'network'
20+
dataType: 'address' | 'transaction' | 'current-wallet' | 'wallets' | 'network'
2121
actionType: 'create' | 'update' | 'delete'
2222
}
2323
type NetworkList = State.Network[]

packages/neuron-wallet/src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ app.on('ready', async () => {
4040
WalletListSubject.pipe(debounceTime(50)).subscribe(({ currentWallet = null, currentWalletList = [] }) => {
4141
const walletList = currentWalletList.map(({ id, name }) => ({ id, name }))
4242
const currentWalletId = currentWallet ? currentWallet.id : null
43-
dataUpdateSubject.next({ dataType: 'wallet', actionType: 'update' })
43+
dataUpdateSubject.next({ dataType: 'wallets', actionType: 'update' })
4444
updateApplicationMenu(walletList, currentWalletId)
4545
})
4646

4747
CurrentWalletSubject.pipe(debounceTime(50)).subscribe(async ({ currentWallet = null, walletList = [] }) => {
4848
updateApplicationMenu(walletList, currentWallet ? currentWallet.id : null)
4949
if (currentWallet) {
50-
dataUpdateSubject.next({ dataType: 'wallet', actionType: 'update' })
50+
dataUpdateSubject.next({ dataType: 'current-wallet', actionType: 'update' })
5151
}
5252
})
5353

packages/neuron-wallet/src/models/subjects/data-update.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Subject } from 'rxjs'
22
import WindowManager from '../window-manager'
33

44
export const DataUpdateSubject = new Subject<{
5-
dataType: 'address' | 'transaction' | 'wallet' | 'network'
5+
dataType: 'address' | 'transaction' | 'wallets' | 'current-wallet' | 'network'
66
actionType: 'create' | 'update' | 'delete'
77
}>()
88

packages/neuron-wallet/src/models/window-manager.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ export default class WindowManager {
88
}
99
}
1010

11-
public static dataUpdated = (meta: { dataType: 'wallet' | 'address' | 'transaction' | 'network' }) => {
11+
public static dataUpdated = (meta: {
12+
dataType: 'current-wallet' | 'wallets' | 'address' | 'transaction' | 'network'
13+
}) => {
1214
if (WindowManager.mainWindow) {
1315
WindowManager.mainWindow.webContents.send('data-updated', meta)
1416
}

0 commit comments

Comments
 (0)