Skip to content

Commit a36abba

Browse files
committed
feat(neuron-ui): make the alert of lacking remote module more clear
The electron app is required explicitly
1 parent 5d56aab commit a36abba

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

packages/neuron-ui/src/services/remote/controllerMethodWrapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type ControllerResponse = SuccessFromController | FailureFromController
1717
export const RemoteNotLoadError = {
1818
status: 0 as 0,
1919
message: {
20-
content: 'remote is not supported',
20+
content: 'The remote module is not found, please make sure the UI is running inside the Electron App',
2121
},
2222
}
2323

packages/neuron-ui/src/services/remote/index.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,28 @@ export * from './networks'
44
export * from './transactions'
55
export * from './skipDataAndType'
66

7+
const REMOTE_MODULE_NOT_FOUND =
8+
'The remote module is not found, please make sure the UI is running inside the Electron App'
9+
710
export const getLocale = () => {
811
if (!window.remote) {
9-
console.warn('remote is not supported')
12+
console.warn(REMOTE_MODULE_NOT_FOUND)
1013
return window.navigator.language
1114
}
1215
return window.remote.require('electron').app.getLocale()
1316
}
1417

1518
export const getWinID = () => {
1619
if (!window.remote) {
17-
console.warn('remote is not supported')
20+
console.warn(REMOTE_MODULE_NOT_FOUND)
1821
return -1
1922
}
2023
return window.remote.getCurrentWindow().id
2124
}
2225

2326
export const validateMnemonic = (mnemonic: string): boolean => {
2427
if (!window.remote) {
25-
console.warn('remote is not supported')
28+
console.warn(REMOTE_MODULE_NOT_FOUND)
2629
return true
2730
}
2831
const { validateMnemonic: remoteValidateMnemonic } = window.remote.require('./models/keys/mnemonic')
@@ -31,7 +34,7 @@ export const validateMnemonic = (mnemonic: string): boolean => {
3134

3235
export const generateMnemonic = (): string => {
3336
if (!window.remote) {
34-
console.warn('remote is not supported')
37+
console.warn(REMOTE_MODULE_NOT_FOUND)
3538
return ''
3639
}
3740
const { generateMnemonic: remoteGenerateMnemonic } = window.remote.require('./models/keys/key')
@@ -40,7 +43,7 @@ export const generateMnemonic = (): string => {
4043

4144
export const showMessage = (options: any, callback: Function) => {
4245
if (!window.remote) {
43-
console.warn('remote is not supported')
46+
console.warn(REMOTE_MODULE_NOT_FOUND)
4447
window.alert(options.message)
4548
} else {
4649
window.remote.require('electron').dialog.showMessageBox(options, callback)
@@ -49,7 +52,7 @@ export const showMessage = (options: any, callback: Function) => {
4952

5053
export const showErrorMessage = (title: string, content: string) => {
5154
if (!window.remote) {
52-
console.warn('remote is not supported')
55+
console.warn(REMOTE_MODULE_NOT_FOUND)
5356
window.alert(`${title}: ${content}`)
5457
} else {
5558
window.remote.require('electron').dialog.showErrorBox(title, content)
@@ -58,7 +61,7 @@ export const showErrorMessage = (title: string, content: string) => {
5861

5962
export const showOpenDialog = (opt: { title: string; message?: string; onUpload: Function }) => {
6063
if (!window.remote) {
61-
window.alert('remote is not supported')
64+
window.alert(REMOTE_MODULE_NOT_FOUND)
6265
}
6366
const { onUpload, ...options } = opt
6467
return window.remote.require('electron').dialog.showOpenDialog(

packages/neuron-ui/src/services/subjects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const FallbackSubject = {
22
subscribe: (args: any) => {
3-
console.warn('remote is not supported')
3+
console.warn('The remote module is not found, please make sure the UI is running inside the Electron App')
44
console.info(JSON.stringify(args))
55
return {
66
unsubscribe: () => {

0 commit comments

Comments
 (0)